How to reduce such noise?
1 view (last 30 days)
Show older comments
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
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.
0 Comments
Answers (1)
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.
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!