![]() |
对损坏的图像进行平均以消除MATLAB中的噪声的问题
我想对零均值高斯加性噪声破坏的.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); [B]回答:[/B] 问题可能是图像数据全部为[URL="https://www.mathworks.com/help/matlab/ref/uint8.html"]uint8[/URL]类型,因此将它们全部加在一起会导致像素值的饱和度达到255,从而为您提供大部分为白色的图像,然后在被除以后最终看起来大部分为黑色图片数量。您应该将图像转换为另一种数据类型,例如[URL="https://www.mathworks.com/help/matlab/ref/double.html"]double[/URL] ,然后执行平均,然后转换回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); [B]旁注:[/B]您应该避免为变量指定与任何现有函数相同的名称,因为这可能导致问题/混乱。这就是为什么我将变量sum更改为imageSum (有内置函数[URL="https://www.mathworks.com/help/matlab/ref/sum.html"]sum[/URL] )。 [url=https://stackoverflow.com/questions/2449780]更多&回答...[/url] |
所有时间均为北京时间。现在的时间是 06:59。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.