gpt4 book ai didi

image - RGB 图像中的噪声去除 MATLAB

转载 作者:行者123 更新时间:2023-12-02 03:23:33 25 4
gpt4 key购买 nike

我正在尝试从已经嘈杂的 RGB 图像中去除噪声。我见过一些例子,其中将盐和胡椒噪声添加到干净的图像中,然后再次将其删除作为示例,但如果这有意义的话,我正在阅读已经嘈杂的图像。由于某种原因,此代码并未对原始图像进行任何更改。噪音根本没有被消除。任何帮助将不胜感激。

train.jpg

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);

最佳答案

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

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

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

关于image - RGB 图像中的噪声去除 MATLAB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54089393/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com