[英]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. 我有5张在不同时间使用CCD拍摄的数字全息图。 I would like to average the 5.
我想平均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. 我可以通过MATLAB中的以下代码来做到这一点,除了无法像在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))
If you transform the image into the uint8
, it would be correct: 如果将图像转换为
uint8
,那将是正确的:
imwrite(uint8(meanImage),'snap10.bmp'); % instead of double
Also, the mean is wrong as you sum 1:10
, but divided the sum by 5
. 同样,当您将
1:10
求和时,均值是错误的,但将和除以5
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.