MATLAB Answers

How to access data with more than 524288 elements?

227 views (last 30 days)

Hi,

I've got the problem to access my data. There are 46 cells and each cell contains 480x640x3 uint8.

I cannot display summaries of variables with more than 524288 elements on the workspace.

Please have a look at the attached image since pictures speak louder than words.

I've tried to extract into individual RGB channel but it is not working for all frames. It's only showed the first frame and got an error 'Index exceeds matrix dimensions'.

load('X:\data_depth\cf1','imagecolor');
[a,~]=size(imagecolor{1,1});
image=imread('X:\data\template.png');
counter=1;
for i = 1:length(imagecolor)
    imagesc(imagecolor{i})
    redChannel = i(:, :, 1);
    greenChannel = i(:, :, 2); 
    blueChannel = i(:, :, 3);
      pause(0.1)
      counter = counter + 1;
  end

How to get the variables of 480x640x3 uint8 in each cell?

Help me, please...

Thank you

Regards

Hana

  2 Comments

Rik
Rik on 26 May 2018
Why are you incrementing a counter? You have a for-loop that can do that for you. Also, you are using i as you loop counter, but then you are treating it as your image. If you put in i=imagecolor{i}; after your call to imagesc, at least that error should be resolved.
hana razak
hana razak on 26 May 2018
I thought I need the counter to keep it looping. Thanks for pointing that out. i=imagecolor{i};,this really did resolve the error. You help me a lot.
Thank you so much

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 26 May 2018
Lots wrong with that.
  1. Don't call your variable image since it's the name of a built in function.
  2. I have no idea what the badly named "image" is or what the template image is supposed to do.
  3. You don't extract the image from the cell array, imagecolor{i} into its own variable.
  4. You are trying to treat the loop index i as if it's an RGB image instead of a simple integer loop index.
You might try something like this:
storedStructure = load('X:\data_depth\cf1','imagecolor');
imagecolor = storedStructure.imagecolor;
% Find out how many images are in the cell array.
numberOfImages = length(imagecolor);
% Read in the template image (for some unknown reason).
templateImage = imread('X:\data\template.png');
for k = 1 : numberOfImages
% Extract this one image from the cell array.
thisImage = imagecolor{k};
imshow(thisImage);
% Extract individual color channels.
redChannel = thisImage(:, :, 1);
greenChannel = thisImage(:, :, 2);
blueChannel = thisImage(:, :, 3);
drawnow;
pause(0.1)
% Now do something with the four image variables.....
end

  5 Comments

Show 2 older comments
hana razak
hana razak on 26 May 2018
Oh, yes. I found them.
Thank you so much for your time and patience.
ahmad Al sarairah
ahmad Al sarairah on 14 Jan 2020
what do you mean by :
storedStructure = load('X:\data_depth\cf1','imagecolor');
how can i change this sentence to apply it on my computer ?
is this path or not?
Image Analyst
Image Analyst on 14 Jan 2020
storedStructure is a structure that has fields for every one of the variables you saved with the save() function. The first argument is the full file name of your .mat file. The second argument is what variable you want to pull out. If you want all variables in the .mat file, then don't include a second argument.
fullFileName = 'C:/users/ahmad/pictures/whatever.mat'; % Your .mat file.
% Read all the variables in.
% They will be put into fields of a structure variable.
storedStructure = load(fullFileName);
% Now get your variable(s) from the structure.
myVar1 = storedStructure.myVar1;
myVar2 = storedStructure.myVar2;

Sign in to comment.

More Answers (0)

Sign in to answer this question.