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

标签 image matlab image-manipulation 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);

最佳答案

问题很可能是图片数据都是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);

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

关于image - 平均损坏图像以消除 MATLAB 中的噪声的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2449780/

相关文章:

android - 调整大小/缩放位图后图像质量不佳

javascript - 图片元素不适用于 onmouseover 和 onmouseout

windows - Matlab 在命令行上运行脚本并阻止直到完成

windows - 尝试在 Windows 上使用 Gulp 调整图像大小时出现 EOF 错误

matlab - 从 Octave 的 fminunc 到 Julia 的带参数梯度函数优化

matlab - 在特定耳塞( channel )上播放歌曲

c++ - 更改 RGB 值

css - 如何使用CSS在悬停时显示图像

iphone - 有没有快速缩放图像的方法?

android - 为联系人添加照片