3

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

jilles de wit
  • 7,060
  • 3
  • 26
  • 50
John
  • 3,888
  • 11
  • 46
  • 84
  • You could state exactly what is the difference you perceive between the "noise" and the object edge – Dr. belisarius Jul 05 '11 at 04:15
  • @belisarius: Thanks for comment. I think it is not precisely to call it "noise". I mean the background (part A), where the color is light green. The object part is the part which has dark green. – John Jul 05 '11 at 04:40

1 Answers1

9

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

Community
  • 1
  • 1
gnovice
  • 125,304
  • 15
  • 256
  • 359