Identify shape in binary picture make it smooth and ignore rest
3 views (last 30 days)
Show older comments
i am trying to identify forged parts of an image and i am having results like the picture below.
How can i :
- identify the bigest object in the picture
- make borders for the object and fill it in, in order to be smooth
- remove any remaining part from the image
in which direction should i go?
0 Comments
Accepted Answer
More Answers (2)
Image Analyst
on 14 Dec 2018
Call imfill() and bwareafilt(). This will not change the shape of the object like imclose() will
mask = imfill(mask, 'holes');
mask = bwareafilt(mask, 1);
where mask is your binary image.
2 Comments
Image Analyst
on 15 Dec 2018
Another way to make the boundary smooth is to blur the image and threshold it:
windowSize = 5; % Whatever
kernel = ones(windowSize)/windowSize^2;
newMask = conv2(double(mask), kernel, 'same') > 0.5;
Has a somewhat different shape than imclose(), especially for larger kernel sizes.
If you need to "make borders for the object", then you can bwboundaries():
boundaries = bwboundaries(mask);
lvas
on 15 Dec 2018
2 Comments
Image Analyst
on 15 Dec 2018
I would still use imfill(). You can do that before your call to imclose(). The reason is, if you have large holes (more than 40 pixels across), the 20 pixel dilation may not be enough to cover that hole. Then you'd still have holes remaining in your region, whereas imfill() will never leave any holes -- it will ALWAYS fill all holes regardless if they are 40 or more pixels in diameter.
You can still use imclose() on it, which will still smooth the boundaries. The closing number will control how smooth the boundaries are - bigger for more smoothing, smaller for less smoothing. Sometimes, for larger numbers, using imclose to smooth boundaries will give artifacts related to the shape of the structuring element, and the blurring might be better. So I'd try it both ways.
See Also
Categories
Find more on 3-D Volumetric Image Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!