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 件のコメント

Jan
Jan 2012 年 4 月 12 日
You forgot to explain the problem.

サインインしてコメントする。

 採用された回答

Andrei Bobrov
Andrei Bobrov 2012 年 4 月 12 日

0 投票

try
fullfile(cd, strcat('Results\',num2str(x(i)),'.jpg'))

4 件のコメント

Jessica
Jessica 2012 年 4 月 12 日
yes i just tried it and gave me so:
Can't open file
"C:\Results\104\.jpg"
for writing.
You may not have write permission.
Error in ==> Retrieval3 at 135
imwrite(image2,fullfile(cd,
'C:\Results\',
num2str(x(i)),'.jpg'));
Jan
Jan 2012 年 4 月 12 日
Does "You may not have write permissions" reveal the source of the problem already?!
Jessica
Jessica 2012 年 4 月 12 日
yes what andrei told me to do worked but now i have the error above
Walter Roberson
Walter Roberson 2012 年 4 月 12 日
You missed the strcat() step, Jessica.

サインインしてコメントする。

その他の回答 (1 件)

Jan
Jan 2012 年 4 月 12 日

0 投票

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 件のコメント

Image Analyst
Image Analyst 2012 年 4 月 12 日
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.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File Exchange で Image Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by