I have 3 480 row x 640 column images. Each pixel holds an intensity value.
I read them in matlab with this:
object_intensities = cell(1,6);
for pat=1:3
file1 = sprintf('image%d.pgm',pat-1);
dummy = double(imread(file1));
object_intensities{pat} = dummy;
end
Now for pat = 1 to 3, object_intensities is a cell array such that each cell element of object_intensities{pat} holds each image in a 480x640 matrix array.
Now what I need is a single structure that is 480 row x 640 column such that each cell element contains the 3 intensities of each image pixel in a single vector like this:
structure{row 1, column 1} = [image1_intensity @ row1 column1 image2_intensity @ row1 column1 image3_intensity @ row1 column1]
structure{row 1, column2} = [image1_intensity @ row1 column2 image2_intensity @ row1 column2 image3_intensity @ row1 column2]
.
.
structure{row 480, column 640} = [image1_intensity @ row480 column640 image2_intensity @ row480 column640 image3_intensity @ row480 column640]
Any way to do this without using loops but through vectorization?
object_intensitiesactually hold a 480-by-640-by-3 matrix? If it does actually hold a single channel image (which I doubt given your use ofimread, you might need to convert it to grey scale first) then trycat(3,object_intensities{:})and you'll get a nice 480-by-640-by-3 matrix. But then I guess you could have just done that when you are reading the images in,,, basically, why would you want the data structure you say you want? It's going to be really hard to work with compared to a regular matrix. - Danimreadwill make your image RGB by default irrespective of if it's greyscale or not. You will still need to do the conversion. - Dan