Finding average of images using for loop.
이전 댓글 표시
Hi,
I have hundreds of images, I Want to read the first 3 image and then get the average and save them in a file. I want to do this for all the images. I tried to do this but I am able to find the average of only first 3 image. Can anyone please help me to implement the following code in a loop? I'm also attaching 6 image for example to try them in a loop.
Folder='G:\trail\'
outdir = 'G:\Avg_Image';
I0 = imread('pic1_1_1.tiff');
sumImage = double(I0); % Inialize to first image.
for i=2:3 % Read first 3 image
rgbImage = imread(['pic1_1_',num2str(i),'.tiff']);
sumImage = sumImage + double(rgbImage);
end
meanImage = sumImage / 3;
imshow(uint8(meanImage));
outname1 = fullfile(outdir, "pic1_");
imwrite(meanImage, outname1);
I will appreciate any kind of help.
채택된 답변
추가 답변 (1개)
Raushan
2023년 3월 16일
편집: Walter Roberson
2023년 3월 17일
댓글 수: 2
Walter Roberson
2023년 3월 17일
imwrite(uint8(sumImage/10), outname1);
That is wrong. You would want
imwrite(uint8(floor(sumImage/k)), outname1);
Raushan
2023년 3월 17일
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!