如何去除图像中物体边缘附近的噪声

发布于 11-18 08:45 字数 182 浏览 4 评论 0 原文

我有这样的图像:

包含噪声的输入图像

我想删除边缘附近的背景(A 部分)物体。我计划使用颜色检测,因为物体和噪声的颜色有点不同。但也许这不是一个好主意。

如果您能为我提供任何想法,我将不胜感激。 谢谢

I have an image like this:

Input image containing noise

I would like to remove the background(part A) near the edge of the object. I plan to use color detection since the color of object and noise are a little bit different. But maybe it is not a good idea.

I would appreciate if you could have any idea for me.
Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绿萝 2024-11-25 08:45:21

如果您要对图像执行任何类型的基于颜色的分割,您可能会发现转换为 HSV 会更容易颜色空间首先选择特定的颜色范围。我在 我对类似问题的回答。您可能想要遵循的步骤如下:

  • 转换为 HSV 并通过选择色调在绿色范围内且具有最小饱和度和值的像素来创建二进制蒙版。
  • 将所得掩模腐蚀一定量以去除小杂散簇。
  • 扩大腐蚀蒙版以使所选像素恢复到更平滑的边缘。

我无法给出如何将这种分析应用于数据的准确示例,因为您在问题中提供的图像实际上比它显示的数据具有更高的分辨率,但这里有一个通用解决方案使用函数RGB2HSVIMERODE 和 "="" rel="nofollow noreferrer">IMDILATE (最后两个来自 图像处理工具箱):

rgbImage = imread('data.jpg');  %# Load the RGB image
hsvImage = rgb2hsv(rgbImage);   %# Convert to HSV color space
hPlane = 360.*hsvImage(:,:,1);  %# Get the hue plane, scaled from 0 to 360
vPlane = hsvImage(:,:,3);       %# Get the value plane
mask = (hPlane >= 80) & (hPlane <= 140) & (vPlane >= 0.3);  %# Select a mask
SE = strel('disk',10);                 %# Create a disk-shaped element
mask = imdilate(imerode(mask,SE),SE);  %# Erode and dilate the mask

下面是一些代码,用于可视化上述分析创建的边缘:

edgeMask = mask-imerode(mask,strel('disk',1));  %# Create an edge mask
edgeImage = zeros([size(edges) 3]);     %# Create an RGB image for the edge
edgeImage(find(edgeMask)) = 1;          %#   that's colored red
image(rgbImage);                        %# Plot the original image
hold on;
image(edgeImage,'AlphaData',edgeMask);  %# Plot the edge image over it

在此处输入图像描述

If you're performing any sort of color-based segmentation of images, you may find it easier to convert to HSV color space first to select specific color ranges. I outline how you can do this sort of thing in an answer I gave to a similar question. The steps you would likely want to follow would be the following:

  • Convert to HSV and create a binary mask by selecting pixels with hues within a green color range and with a minimum amount of saturation and value.
  • Erode the resulting mask by a certain amount to remove small spurious clusters.
  • Dilate the eroded mask to get back to a smoother edge for your selected pixels.

I can't give an exact example of how you would apply this analysis to your data since the image you provide in the question actually has a higher resolution than the data it displays, but here's a general solution that uses the functions RGB2HSV, IMERODE, and IMDILATE (the last two are from the Image Processing Toolbox):

rgbImage = imread('data.jpg');  %# Load the RGB image
hsvImage = rgb2hsv(rgbImage);   %# Convert to HSV color space
hPlane = 360.*hsvImage(:,:,1);  %# Get the hue plane, scaled from 0 to 360
vPlane = hsvImage(:,:,3);       %# Get the value plane
mask = (hPlane >= 80) & (hPlane <= 140) & (vPlane >= 0.3);  %# Select a mask
SE = strel('disk',10);                 %# Create a disk-shaped element
mask = imdilate(imerode(mask,SE),SE);  %# Erode and dilate the mask

And here's some code to visualize the edges created by the above analysis:

edgeMask = mask-imerode(mask,strel('disk',1));  %# Create an edge mask
edgeImage = zeros([size(edges) 3]);     %# Create an RGB image for the edge
edgeImage(find(edgeMask)) = 1;          %#   that's colored red
image(rgbImage);                        %# Plot the original image
hold on;
image(edgeImage,'AlphaData',edgeMask);  %# Plot the edge image over it

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文