How to average a set of images and save the averaged image as the averaged image using MATLAB

image matlab image-processing

47 观看

1回复

19 作者的声誉

I have 5 digital holograms that I recorded using a CCD at different times. I would like to average the 5.

I am able to do that by the following code in MATLAB, except that I am unable to save the file as I see in MATLAB. Instead I get a white image after saving.

I0 = imread('snap1.bmp');
sumImage = double(I0); % Inialize to first image.
for i=2:10 % Read in remaining images.
  rgbImage = imread(['snap',num2str(i),'.bmp']);
  sumImage = sumImage + double(rgbImage);
end;
meanImage = sumImage / 5;

figure
imshow(meanImage,[])
imwrite(double(meanImage),'snap10.bmp')

o=imread('snap10.bmp');
figure
imagesc((o))

images can be found at

作者: sanjeev 的来源 发布者: 2017 年 12 月 27 日

回应 1


1

10118 作者的声誉

决定

If you transform the image into the uint8, it would be correct:

imwrite(uint8(meanImage),'snap10.bmp'); % instead of double

Also, the mean is wrong as you sum 1:10, but divided the sum by 5.

作者: OmG 发布者: 2017 年 12 月 27 日
32x32