create a loop image processing

25 Ansichten (letzte 30 Tage)
Edmilson Carvalho
Edmilson Carvalho am 12 Mär. 2019
Kommentiert: Geoff Hayes am 13 Mär. 2019
hello im trying to do image processing for 279 images starting from 0240 to 0519, im unsing the comand bellow but it is only processing the last images, im sending the code that im using
%%%
for n=240:519
images{n} = imread(sprintf('pentan1h_6uLmin_0%3d.tif',n));
imshow(images{n},[],'initialmagnification','fit');
end
%crop the image
[ny, nx]= size(images{n});
rect=[105 35 820 460];
J1=imcrop(images{n},rect);
figure, imshow(J1,[],'initialmagnification','fit');
%%
rgbImage =J1;
subplot(1, 2, 1);
imshow(rgbImage);
title('Original Image', 'FontSize', 20);
%%
% Extract the individual red, green, and blue color channels.
redChannel = rgbImage(:, :, 1);
greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
meanR = mean2(redChannel)
meanG = mean2(greenChannel)
meanB = mean2(blueChannel)
%%
rgbImage = cat(3, redChannel - meanR, greenChannel - meanG, blueChannel - meanB);
subplot(1, 2, 2);
imshow(rgbImage);
title('Means Subtracted', 'FontSize', 20);
%blue and Red
meanB/meanR

Antworten (1)

Geoff Hayes
Geoff Hayes am 13 Mär. 2019
Edmilson - look carefully at your for loop
for n=240:519
images{n} = imread(sprintf('pentan1h_6uLmin_0%3d.tif',n));
imshow(images{n},[],'initialmagnification','fit');
end
All it is doing is reading in each of the images and then showing that image (perhaps it shows all the images in individual figures or perhaps not...I suspect the latter). But all the processing is happening outside of the loop and so will only be applied to the last image. You probably want to move all that code into the body of the for loop...though you may need to update it so that you don't have 279 (or more) figures appearing (or maybe that is what you want?).
  2 Kommentare
Edmilson Carvalho
Edmilson Carvalho am 13 Mär. 2019
thanks for the help it is working now, but now i have other question can someone help me to creat a code that can exctrat the exaxt time in s that the picture was taken.
Geoff Hayes
Geoff Hayes am 13 Mär. 2019
You could try iminfo and the FileModDate property..but this might not be exactly what you want. I'm not sure if the "exact time the picture was taken" is a property of the file (or if it is, can MATLAB determine it).

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by