필터 지우기
필터 지우기

How to save series of images?

조회 수: 2 (최근 30일)
Steven
Steven 2013년 12월 18일
편집: Steven 2013년 12월 18일
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.

채택된 답변

Image Analyst
Image Analyst 2013년 12월 18일
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
Steven
Steven 2013년 12월 18일
편집: Steven 2013년 12월 18일
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 2013년 12월 18일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Code Generation, GPU, and Third-Party Support에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by