平均损坏的图像以消除MATLAB中的噪声的问题

ame*_*ara 4 matlab image-manipulation image corruption noise

我想平均一些被零均值高斯加性噪声破坏的.jpg图像.在搜索之后,我想出了添加图像矩阵并将总和除以矩阵的数量.但是,得到的图像是全黑的.通常,当图像数量增加时,结果图像变得更好.但是当我使用更多图像时,它会变暗.

我使用800x600黑白.jpg图像.这是我使用的脚本:

image1 = imread ('PIC1.jpg');
image2 = imread ('PIC2.jpg');
image3 = imread ('PIC3.jpg');
image4 = imread ('PIC4.jpg');

sum = image1 + image2 + image3 + image4; 
av = sum / 4; 
imshow(av);
Run Code Online (Sandbox Code Playgroud)

gno*_*ice 10

问题可能是图像数据都是类型的uint8,所以将它们全部添加会导致像素值的值达到255的饱和度,从而为您提供一个大部分白色的图像,然后当您再除以图像数量.您应该将图像转换为其他数据类型,例如double,然后执行平均,然后转换回uint8:

% Load your images:
image1 = imread('PIC1.jpg');
image2 = imread('PIC2.jpg');
image3 = imread('PIC3.jpg');
image4 = imread('PIC4.jpg');

% Convert the images to type double and sum them:
imageSum = double(image1) + double(image2) + double(image3) + double(image4);

% Divide by the number of images and convert back to type uint8:
averageImage = uint8(imageSum./4);

% Display the averaged image:
imshow(averageImage);
Run Code Online (Sandbox Code Playgroud)

侧面注意:您应该避免为变量提供与任何现有函数相同的名称,因为这可能会导致问题/混淆.这就是为什么我将变量更改sumimageSum(有一个内置函数sum).


Amr*_*mro 7

使用图像处理工具箱中的IMLINCOMB的替代解决方案:

I = imlincomb(0.25,I1, 0.25,I2, 0.25,I3, 0.25,I4);
Run Code Online (Sandbox Code Playgroud)

  • imlincomb解决方案很不错,因为它不会产生任何双精度图像副本.输出图像与输入图像(uint8)的类型相同,因此您不必担心缩放. (4认同)