How to save series of images?

2 visualizzazioni (ultimi 30 giorni)
Steven
Steven il 18 Dic 2013
Modificato: Steven il 18 Dic 2013
Hi.
I am reading and doing a bunch of stuff on a series of images.
But I want to save every thing done on every image for future use. How can I do so?
I mean, for example, I have read 100 images and just turn them into binary. How can I save all of them in binary in the workspace for further use?
By saving I do not mean writing the images, I mean keep them in the memory and workspace.
I can't use something like
. . .
binaryImage (i) = ... (i is the index of the loop in which the process is done)
because it confuses with dimensions of the image.
What can I do?
Thanks a lot.

Risposta accettata

Image Analyst
Image Analyst il 18 Dic 2013
Steven/Mohammad:
If you have a script, then any variables are left hanging around in the base workspace. If they are in a function, then vanish when the function exits. To use variables in a function in the future elsewhere, you need to return them as output arguments. Or else use the methods described in the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F
By the way if you want to save images in a loop, you need to save either to a 3D array
if i == 1
binaryImage3D = thisBinaryImage; % The first time, initialize
else
binaryImage3D = cat(3, binaryImage3D, thisBinaryImage);
end
or save it into a cell of a cell array where you use braces instead of parentheses.
allBinaryImages{i} = thisBinaryImage;
You can read the FAQ on cell arrays for a good description of cell arrays: http://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F
  2 Commenti
Steven
Steven il 18 Dic 2013
Modificato: Steven il 18 Dic 2013
Thanks for your reply.
1. I used something like this:
allBinaryImages(i,:,:)=thisBinaryImage(:,:)
Now I could save them, but I could not load them again! I mean when later I wanted to for example imshow one of them, say allBinaryImages(3,:,:), I always come to an error which I do understand, but do not know how to solve it.
So, how can I for example later, show one of those allBinaryImages? because now they are 3 dimensions.
2. By the way! I sent you a message. I would be very grateful if you will reply to me (or shall I ask it here?)
Thanks so much for your time.
Image Analyst
Image Analyst il 18 Dic 2013
1. You need to have i be the last index, not the first. And you don't need the (:,:) on the array:
allBinaryImages(:, :, i) = thisBinaryImage;
To show one particular plane from that 3D image, you'd select it
imshow(allBinaryImages(:,:, 42)); % Show image #42.
2. I don't take email. The email account I used for this account is a temporary one that I never monitor, can't take attachments to, and can't reply from. It's just a spam catcher account, as you can see by going to mailinator.com and typing in imageanalyst. Anyone, even you, can login with no password and see all the complete garbage that I'd be getting in my mail email if I had used that. You can replay here and there's a 95% chance I'll see it.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by