What is the efficient way to read the images from the subfolders?

I saved the file location on the variable (1*815 cell array). I used the following code to read the image. But however I am getting out of Memory error in Windows 7, Matlab 2015 trail version
for i=1:815
ni(i)=imread(char(fullFileName(1,i)));
end
Any help is appreciated
Thanks in Advance

Réponses (1)

for K = 1:length(fullFileName)
ni{K} = imread(fullFileName{K});
end
If your images are large enough, you will run out of memory trying to store all of them in memory simultaneously. If so then be sure to use 64 bit MATLAB and increase your physical memory or your swap space (but swap space is slow!!!). Or reconsider your code to figure out whether you really need all of the images to be in memory at the same time.

8 commentaires

Thanks for your response. I am using 64 bit version only.
Even a 64 bit version of MATLAB can run out of RAM if you read in more data than your RAM can handle.
You did not say how you are using the data so we cannot comment on whether there are other approaches that might not need all of it in memory at the same time.
Jabasan, why do you want to put all the images into a cell array? Will you need them after the loop exits? Probably not. Even if you do, it would probably be more efficient just to read them in from disk again rather than use up gigabytes of RAM storing images.
Thanks Image Analyst. I tried like this
for i=1:812
n=volread(fullFileName{i});
mri=n.img;
[Nx,Ny,Nz]=size(mri);
%3 Level 3DWT
w=wavedec3(mri,3,'haar');
sb=w.dec;
end
Is it the good way? Thanks
I do not see anything in your description that requires that you compute anything between images ? Other than that you care calculating 44 features per image to end up with an 812 x 44 result. It does not sound like you are, for example, calculating the average of each voxel like a time series.
The following is the problem I am facing now :-
In the following code , for each value of i, the wavedec3 function returns 22 subbands and the feat_vect will return 20*1 vector. I am getting the output just for single i value. I am very much confused with cell array that how to provide result as M should contain {i}images inside each image, {22subbands} further inside the subbands of each,{20*1vector}
for i=1:3 n=volread(fullFileName{i}); %%% Read 3D volume struct mri=n.img; %%% Read the 3D volume image [Nx,Ny,Nz]=size(mri); %3 Level 3DWT w=wavedec3(mri,3,'haar'); sb=w.dec; %%% 22 subbands while k<=length(sb) [M{i}{k,1}]=feature_vec(sb{k,1});k=k+1; %%% feature_vec returns 20*1 vector end end

Connectez-vous pour commenter.

Catégories

Question posée :

Jab
le 12 Sep 2015

Commenté :

le 13 Sep 2015

Community Treasure Hunt

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

Start Hunting!

Translated by