Reshaping Blobs in a Binary
Show older comments
When processing an image with low contrast, I inevitably will distort some of the shapes when I threshold the grayscale image and convert it to binary.
Is there any way to reshape blobs after I have done the conversion to binary? I know the shapes should all be circular, but most have tails or look elongated.
1 Comment
Ryan
on 20 Jun 2012
Do you have a sample image? Are you doing any processing before the threshold?
Accepted Answer
More Answers (2)
Image Analyst
on 20 Jun 2012
0 votes
Perhaps, but it's not easy. Let's say you have a comet-shaped blob - pointier at one end than the other. Use bwboundaries() to get all the boundary coordinates. Use regionprops to get the equation of the major axis, using orientation and centroid. Then take the coordinate from each half of the blob. Half will come from the pointy side and half from the larger, rounder size. Scan each set of coordinates to find the minimum curvature over a range of pixels, say 10 or 20 pixels. The side with the larger minimum radius of curvature will be the circular side and the side with the smaller minimum radius of curvature will be the pointy side.
Alternatively you can use bwmorph('skel') to get the skeleton. Then, perhaps you can use bwmorph('endpoints') to get the ends of the skeleton and see which is closer to a boundary point. The endpoint at the pointy tail end will be closer to the nearest boundary point than the endpoint at the larger round head end. The circle would then be placed at the round head end with a radius equal to, say, the average distance of the closest 10 boundary points. Good luck.
Ryan
on 20 Jun 2012
0 votes
use region props area measurements and dilate the centroid points with a disk structuring element with the appropriate radius (assume circle and use A = pi*r^2). I have also read some academic papers in the past where they filled areas with the largest circle possible, but I am not sure how to program that.
For area of the circle, you could also use "EquivDiameter" from the regionprops.
5 Comments
Image Analyst
on 20 Jun 2012
If you have a blob with a long tail, the centroid will not be in the round head, but will be shifted toward the tail so the circle would not overlap the round head part. In the latter half of your answer you may be thinking of the skeleton. The skeleton traces out the locations of the largest circle that can fit inside the blob.
Ryan
on 20 Jun 2012
I was assuming exact positioning did not matter because he is willing to reshape. I am unsure how to do that with the skeleton, or maybe I am thinking of the wrong skeleton.
* I updated my answer to add mention of "EquivDiameter" with the region props command.
Image Analyst
on 20 Jun 2012
If he had some weird roundish shaped blob and he wanted a round one then he could use the centroid and EquivDiameter to place circles over the blobs. If he wanted the round part of a comet and wanted to discard the tail, then this would mislocate the circle. Your suggestion of uploading and image is a good one. He should also supply an image where he drew the circle outlines on it so we can see what he's really after. Of course the best way is to increase the contrast in the image capture step rather than try to fix it in the image processing step. For example adding more contrast solution, or lighting, or change the color of the lighting, or add fluorescent tagging material, or use dark field illumination or some other kind of illumination, or whatever.
Caleb
on 20 Jun 2012
Caleb
on 20 Jun 2012
Categories
Find more on Image Filtering in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!