Auto save file name by using original name

4 ビュー (過去 30 日間)
takem
takem 2011 年 6 月 16 日
I'm using the Image Processing Toolbox for MATLAB to do analysis on some images. I want to create a loop so that I can process multiple files. At the end of the loop, I will be plotting some images onto one figure. Then, I want to save it with the original filename, and add "-XYZ" at the end.
Is there a way to make this process automatic, so the script will perform the required analysis, plot the images, save, then move on to the next image? Also, is there a way to create an excel or txt document at the end of each image analysis?
Right now my code looks like:
originalImage = imread('file.jpg');
bw = im2bw(originalImage, 0.85);
a = bwarea(bw)
b = bwarea(~bw)
h = figure
subplot(1,3,1), imshow(originalImage), title('A')
subplot(1,3,2), imshow(bw); title('B')
subplot(1,3,3), imshow(~bw); title('C')
print(h, '-dtiff ', 'test');

回答 (3 件)

Gerd
Gerd 2011 年 6 月 16 日
Hi takem,
do to the fact you have the handle to your new figure you can use
saveas(h,[filepath '\' Savefilename Savefileextension],'jpg');
You have to use the filepath and filename from which you loaded your original image and append your application specific comment.
Gerd
  1 件のコメント
takem
takem 2011 年 6 月 16 日
Thank you so much, I used this.

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


Walter Roberson
Walter Roberson 2011 年 6 月 16 日
Please have a look at this FAQ
  1 件のコメント
takem
takem 2011 年 6 月 16 日
Thank you so much, I used this.

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


Walter Roberson
Walter Roberson 2011 年 6 月 16 日
I guess you realized by now that the solution to the question you deleted was:
Do not im2bw(fullFileName, 0.85) -- instead im2bw(imageArray, 0.85)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by