How to reduce such noise?

1 view (last 30 days)
AnG
AnG on 12 Oct 2013
Commented: AnG on 13 Oct 2013
I have a code that simply estimates the boundaries of objects in an image for further processing
f = imread(ImageFile);
i = rgb2gray(f);
threshold = graythresh(i);
bw = im2bw(i, threshold);
imshow(bw)
se = strel('disk',3);
bw = imclose(bw,se);
bw = bwareaopen(bw, 30);
[B,L] = bwboundaries(bw,'noholes');
imshow(label2rgb(L, @jet, [.5 .5 .5]))
hold on
for k = 1:length(B)
boundary = B{k};
plot(boundary(:,2), boundary(:,1), 'w', 'LineWidth', 2)
end
It works well with this image.
However when I tried it with this one (and a few similar ones) the results were not even close to being perfect. I tried using Wiener filter, it smoothed out left part of the image but the right part still has a lot of noise. Median filter makes it worse.
What would be the most effective way to reduce such noise? Also I am looking for a generalized solution so that when I use it with images with similar background it still works.

Answers (1)

Image Analyst
Image Analyst on 12 Oct 2013
The problem is that im2bw is notoriously bad at finding thresholds unless you have high contrast objects on a uniform background, and the objects must have enough area compared to the whole image. You need to do a background correction - try adapthisteq() to do a locally adaptive CLAHE background correction. Or follow this demo: http://www.mathworks.com/help/images/examples/correcting-nonuniform-illumination.html. Then try im2bw() again, or use a better thresholding algorithm, like triangle or something.
  1 Comment
AnG
AnG on 13 Oct 2013
I did it by subtracting the background from images which I captured as a reference. It works 90% of the time and the only problem is with shadows but that can be corrected with proper lighting. Thank you for the link, I will try this method too.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!