首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >基于MATLAB的rgb图像去噪

基于MATLAB的rgb图像去噪
EN

Stack Overflow用户
提问于 2019-01-08 18:05:09
回答 1查看 1K关注 0票数 2

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

代码语言:javascript
复制
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);
EN

回答 1

Stack Overflow用户

发布于 2019-01-08 23:00:58

作为Ander Biguri commented,有许多方法可以降低图像中的噪声。在这里枚举它们都超出了堆栈溢出的范围。但我会建议一种方法:中值滤波。我建议这样做是因为你已经在这么做了!

您正在将medfilt2应用于输入图像的每个通道。只需跳过后面的所有内容,只保留最后一行:将通道连接回RGB图像。

代码语言:javascript
复制
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);

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

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54089393

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档