How to average a set of images and save the averaged image as the averaged image using MATLAB
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.
作者: sanjeev 的来源 发布者: 2017 年 12 月 27 日
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))
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