save an image in a directory

조회 수: 3 (최근 30일)
azarm
azarm 2011년 8월 17일
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