Reading Multiple Images Using For Loop
Show older comments
Hi,
I am trying to use a for loop to read 4 images (of the format 1.jpg,2.jpg etc...) and then calculate the value and location of the minimum pixel of each image. Below is the code I have so far:
RGB=cell(1,4);
for i=1:4
RGB{i}=imread(sprintf('%d.jpg',i)); %Converting the image in to a RGB matrix
gray{i}=rgb2gray(RGB{i}); %Converting the RGB image to grayscale
gray_double{i}=double(gray{i}); %Changing from uint8 format to double
Min_pixel{i}=min(gray_double{i}(:)); %Finding the minimum pixel value
[row, column] = find(gray_double == Min_pixel,1);%Finding location of first minimum
end
The code works up until Line 8 where it struggles to obtain the minimum pixel value. Is there an easier way to do this?
Once again, any help would be much appreciated!
Thank you
Accepted Answer
More Answers (0)
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!