Connected region (grayconnected)
9 views (last 30 days)
Show older comments
Hi all,
I am using the grayconnected() function (multiplication of grayconnected on all 3 color layers) in order to obtain a mask of a part of the image that is separated by a black line (example given bellow).
You can see how the first line is consistent and it devides the image (using grayconnected), but the second line is not.
For this example I would like to have 3 different masks, but because the bottom line is not consistent, I am getting only 2.
I can't use imclose() on the black lines, because in some cases the lines are very dense, so imclose() will turn my image into one big black blob.
Is there a way to specify (using grayconnected) how many pixels do I consider as "connected" (so that a hole 1-2 pixel wide would not be considered as a connection between two regions)?
Should I consider a different approach?
Thank you very much.

0 Comments
Answers (1)
Image Analyst
on 3 Mar 2019
What tolerance value did you use in your call to grayconnected()? Did you try adjusting it? Attach your original image and code.
4 Comments
Image Analyst
on 3 Mar 2019
I'd probably try 4-connected labeling instead of the default 8-connected. That will help.
You might also try watershed to split apart the blobs, if needed.click here
Or you might try a simple erosion to enlarge all the black lines.
See Also
Categories
Find more on Convert Image Type 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!