I want to read a sequence of gray scale images of size 256*256 from memory and开发者_如何学运维 store in a array. Later I want to access individual pixels of each image from array. How can i do this?
Do you mean something like:
NumImages = 20;
% reading
for Ind = 1:NumImages
% replace by your read image function
ImgArray(:, :, Ind) = rand(256, 256);
end
% accessing the pixel in place (1, 2) of the 3rd img in array
SinglePixel = ImgArray(1, 2, 3);
Assuming that you have 6 256x256 images named by 'IM1.jpg' to 'IM6.jpg', in the folder 'C:\ImagesSeq\'. Now you want to read these into Matlab.
IMArray=zeros(256,256,6); % preallocate the memonry for your image array
for i=1:6 % you can replace 6 by any number you need
Filename=sprintf('C:/ImagesSeq/IM%d.jpg',i);
IMArray(:,:,i)=imread(Filename);
end
% you can now accessing the pixel as last answer shows by indexing the Image array
SinglePixel = IMArray(1, 2, 3);
I hope this is what you mean....:)
精彩评论