Filter löschen
Filter löschen

Problem with imwrite

1 Ansicht (letzte 30 Tage)
Jessica
Jessica am 12 Apr. 2012
Dear Sir,
i am trying to use imwrite to save some images i selected from my database to put them in a new folder
i used this : image2= imread(['C:\Database\',num2str(x(i)),'.jpg']);
imwrite(image2,fullfile(cd, strcat('C:\Results\',image2,'.jpg')));
would you guide me to solve this?
Thank you
  1 Kommentar
Jan
Jan am 12 Apr. 2012
You forgot to explain the problem.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 12 Apr. 2012
try
fullfile(cd, strcat('Results\',num2str(x(i)),'.jpg'))
  4 Kommentare
Jessica
Jessica am 12 Apr. 2012
yes what andrei told me to do worked but now i have the error above
Walter Roberson
Walter Roberson am 12 Apr. 2012
You missed the strcat() step, Jessica.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Jan
Jan am 12 Apr. 2012
This is not valid:
fullfile(cd, strcat('C:\Results\',image2,'.jpg'))
While cd is the current directory, you cannot append the path 'C:\...'. Most likely you want:
fullfile('C:', 'Results', [image2, '.jpg'])
or directly:
['C:\Results\', image2, '.jpg']
to construct the file name.
  1 Kommentar
Image Analyst
Image Analyst am 12 Apr. 2012
Or (my favorite) use sprintf() to construct your base filename:
baseFileName = sprintf('Results %d.PNG', imageNumber);
fullFileName = fullfile(folder, baseFileName);
Note that I use PNG for lossless compression and better saved image quality, rather than JPG.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by