create a loop image processing
25 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
Geoff Hayes
2019-3-13
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 个评论
Geoff Hayes
2019-3-13
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).
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!