【发布时间】:2019-06-03 00:05:12
【问题描述】:
我正在尝试从已经有噪点的 RGB 图像中去除噪点。我已经看到了一些示例,其中将椒盐噪声添加到干净的图像中,然后作为示例再次删除,但是如果有意义的话,我正在阅读已经有噪声的图像。由于某种原因,此代码不会对原始图像进行任何更改。根本没有消除噪音。任何帮助将不胜感激。
p = imread("train.jpg");
redChannel = p(:, :, 1);
greenChannel = p(:, :, 2);
blueChannel = p(:, :, 3);
% Median Filter the channels:
redMF = medfilt2(redChannel, [3 3]);
greenMF = medfilt2(greenChannel, [3 3]);
blueMF = medfilt2(blueChannel, [3 3]);
% Find the noise in the red.
noiseImage = (redChannel == 0 | redChannel == 255);
% Get rid of the noise in the red by replacing with median.
noiseFreeRed = redChannel;
noiseFreeRed(noiseImage) = redMF(noiseImage);
% Find the noise in the green.
noiseImage = (greenChannel == 0 | greenChannel == 255);
% Get rid of the noise in the green by replacing with median.
noiseFreeGreen = greenChannel;
noiseFreeGreen(noiseImage) = greenMF(noiseImage);
% Find the noise in the blue.
noiseImage = (blueChannel == 0 | blueChannel == 255);
% Get rid of the noise in the blue by replacing with median.
noiseFreeBlue = blueChannel;
noiseFreeBlue(noiseImage) = blueMF(noiseImage);
% Reconstruct the noise free RGB image
rgbFixed = cat(3, noiseFreeRed, noiseFreeGreen, noiseFreeBlue);
figure, imshow(rgbFixed);
【问题讨论】:
-
对于给定的通道,您只用全色 (R/G/B=255) 或无色 (R/G/B=0) 替换像素,并使用本地过滤值 - I怀疑有很少的像素符合这个标准,所以你没有删除很多!如果您更改了
noiseImage条件,您可能会看到更大的变化。尝试将其设置为完全正确(即redChannel >= 0),然后您将看到medfilt2函数的整体效果,并决定它在哪里有效。 -
谢谢。我可以看到这对于噪点严重的图像不会非常有效。有没有其他方法可以推荐?我已经考虑过转换为 hsv 并消除每个通道的噪音,但我不确定该怎么做。
-
此范围更新将问题置于我的领域之外,并且可能使其对于 stackoverflow 而言过于宽泛...
-
@PremierHottubs 虽然椒盐噪声很适合用于说明目的,但在自然图像中却很少见(除非您的相机坏了)。现在,图像去噪在过去 30 年中一直是一个活跃的研究领域,因此没有“如何做”,或者更确切地说,“如何做”有数千种方法。你真正需要的是一本图像处理/图像去噪方面的好书!
标签: image matlab image-processing rgb