save an image in a directory

1 次查看(过去 30 天)
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

采纳的回答

Fangjun Jiang
Fangjun Jiang 2011-8-17
Why not use print() directly.
print('-dtiff',fullFileName)
  2 个评论
azarm
azarm 2011-8-17
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 2011-8-17
solved with print('-dtiff',fullFileName)!
tnx

请先登录,再进行评论。

更多回答(1 个)

Jan
Jan 2011-8-17
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 个评论
Jan
Jan 2011-8-17
@Fangjun: Mei shi. Wo hen goaxing.
Fangjun Jiang
Fangjun Jiang 2011-8-17
Nice! You are right. You speaks my mother tongue. You got talent, Jan!

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by