0

Using Matlab, I have 1000 color images, their histograms have the size either 384*256*3 or 256*384*3, so they are matrices. I want to number them, and later retrieve them. I know I cannot do this:

for z=1:1000
H(:,:,:,z)={imread(strcat('image.orig/',int2str(z-1),'.jpg'))};
end

But my question is how can I number the 1000 matrices and later I can get any of them, like for the first image, simply using

H(:,:,:,1)

to get the matrix. I know their sizes are different so I cannot set

H=zeros(384,256,3,1000);

because that only work for the matrices of the size 384*256*3.

So what I should do to save the matrices and simply using a number from 1 to 1000 within a variable name to get any of the matrix?

It is just how can I number different matrices and get each of them later?

Hope I stated clear what's my problem. Thanks in advance!!

i_a_n
  • 139
  • 1
  • 1
  • 8
  • Have you tried a `cell` array? `H{z} = imread(...)`. Sizes can be different, data types different, etc. – chappjc Oct 21 '14 at 01:05

1 Answers1

2

As chappjc said, it is better to store in a cell.

H=cell(1000,1);

for z=1:1000
    H{z}=imread(strcat('test',int2str(z),'.jpg'))
end
rayryeng
  • 102,964
  • 22
  • 184
  • 193
chengvt
  • 543
  • 3
  • 17
  • Welcome to StackOverflow! I edited your post for code formatting. In the future, to make your code nicely formatted, I recommend you have a look here: http://meta.stackexchange.com/questions/22186/how-do-i-format-my-code-blocks . Have fun! – rayryeng Oct 21 '14 at 02:08