Connected region (grayconnected)
조회 수: 4 (최근 30일)
이전 댓글 표시
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/206622/image.png)
댓글 수: 0
답변 (1개)
Image Analyst
2019년 3월 3일
What tolerance value did you use in your call to grayconnected()? Did you try adjusting it? Attach your original image and code.
댓글 수: 4
Image Analyst
2019년 3월 3일
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.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!