如何平均一组图像并使用MATLAB将平均图像保存为平均图像

问题描述 投票:0回答:1

我有5个数字全息图,我在不同的时间用CCD记录。我想平均5分。

我可以通过MATLAB中的以下代码来做到这一点,除了我无法保存文件,就像我在MATLAB中看到的那样。相反,我保存后会得到一张白色图片。

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

image matlab image-processing
1个回答
1
投票

如果您将图像转换为uint8,它将是正确的:

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

此外,平均值是错误的,因为你总和1:10,但除以5总和。

© www.soinside.com 2019 - 2024. All rights reserved.