save an image in a directory

Hi, I used: print('-dtiff','example.tif') in my code. now, i need to save the image (example.tif) in a specified directory. My code is: baseFileName = sprintf('TEST%d.tif', j); fullFileName = fullfile(pathName, baseFileName); imwrite(example, fullFileName);
but this error occurs: ??? Undefined function or variable 'example' any idea?
tnx, Azi

 Réponse acceptée

Fangjun Jiang
Fangjun Jiang le 17 Août 2011

0 votes

Why not use print() directly.
print('-dtiff',fullFileName)

2 commentaires

azarm
azarm le 17 Août 2011
My problem with using print is that, i want the resulted image to be saved like this automatically after each running:
TEST1.tif
TEST2.tif
...
that's the reason i used : sprintf('TEST%d.tif', j)- j will be incremented each time.
any suggestion?
tnx
azarm
azarm le 17 Août 2011
solved with print('-dtiff',fullFileName)!
tnx

Connectez-vous pour commenter.

Plus de réponses (1)

Jan
Jan le 17 Août 2011

0 votes

Look in the documentation of IMWRITE: IMWRITE(A, filename) expects A to be an array containing the pixel values. But in your code "example" is not a defined variable.
I assume you want to move the file:
movefile('example.tif', fullFileName);
Most likely Jiang's answer would be better: Sinmply create the picture file at the wnated location directly.

4 commentaires

Jan
Jan le 17 Août 2011
@Jiang: I still do not know, if Jiang is your "first" name. Should I write "@Fangjun"?
Fangjun Jiang
Fangjun Jiang le 17 Août 2011
@Jan, Thank you for asking. Fangjun is my first name. But I really don't mind.
Jan
Jan le 17 Août 2011
@Fangjun: Mei shi. Wo hen goaxing.
Fangjun Jiang
Fangjun Jiang le 17 Août 2011
Nice! You are right. You speaks my mother tongue. You got talent, Jan!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Startup and Shutdown dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by