我要平均其通过零均值高斯噪声添加剂损坏一些.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);

边注:您应该避免给您的变量相同名称的任何现有的功能,因为这可能会导致问题/混淆。这就是为什么我改变了可变sumimageSum(有一个内置的功能 sum )。

其他提示

使用的备选解决方案 IMLINCOMB从图像处理工具箱

I = imlincomb(0.25,I1, 0.25,I2, 0.25,I3, 0.25,I4);

您还可以使用于imagesc(averageImage); 这与自动缩放功能的图像,并且不会显得黑

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top