【问题标题】:Noise removal from rgb image MATLAB从 rgb 图像 MATLAB 中去除噪声
【发布时间】: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


【解决方案1】:

作为Ander Biguri commented,有很多方法可以减少图像中的噪点。在这里枚举它们超出了 Stack Overflow 的范围。但我会建议一种方法:中值过滤。我建议这样做,因为您已经在这样做了!

您正在将medfilt2 应用于输入图像的每个通道。只需跳过后面的所有内容,只保留最后一行:将通道连接回 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]);

rgbFixed = cat(3, redMF, greenMF, blueMF)

figure, imshow(rgbFixed);

由于您的图像非常嘈杂,您可能需要增加过滤器的大小。但是你会在噪音和模糊之间做出妥协。

【讨论】:

    猜你喜欢
    • 2013-08-01
    • 1970-01-01
    • 2014-05-22
    • 2023-04-05
    • 2012-01-26
    • 1970-01-01
    • 2021-08-16
    • 2011-12-30
    • 1970-01-01
    相关资源
    最近更新 更多