Auto save file name by using original name
3 views (last 30 days)
Show older comments
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');
0 Comments
Answers (3)
Gerd
on 16 Jun 2011
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
Walter Roberson
on 16 Jun 2011
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)
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!