Auto save file name by using original name

10 vues (au cours des 30 derniers jours)
takem
takem le 16 Juin 2011
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');

Réponses (3)

Gerd
Gerd le 16 Juin 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
  1 commentaire
takem
takem le 16 Juin 2011
Thank you so much, I used this.

Connectez-vous pour commenter.


Walter Roberson
Walter Roberson le 16 Juin 2011
Please have a look at this FAQ
  1 commentaire
takem
takem le 16 Juin 2011
Thank you so much, I used this.

Connectez-vous pour commenter.


Walter Roberson
Walter Roberson le 16 Juin 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)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by