Trace boundaries of objects in NOT binary images

Hello,
I'd need some help. I need to trace region boundaries in an image. I would need exactly what bwboundaries does but in multi-label images because my image is not binary.
I have a lot of objects, holes, objects inside other objects ... I have to detect all the objects and get its boundaries. I have found only bwboundaries but i couln't find anything for not binary images.
Thank you very much

 Accepted Answer

You can binarize the image and then call it
binaryImage = labeledImage > 0
If the objects are touching and still labeled (which you must have done with a custom algorithm) then you will need multiple binary images:
binaryImage = labeledImage == labelNumberThatYouWant;
do it for every label number that you want the boundary of.

5 Comments

If I understand I would have a binary image for each object. I mean, if I have 5 objects (labeled from 1 to 5) I would have 5 binary images and I would run bwboundaries for each one.
Ok! I thougth that maybe exist a function similar to bwboundaries but for this kind of images.
Thanks
Most likely you do not need to do that because in nearly all situations, the labels don't touch. Perhaps you're thinking of a classified image instead of a labeled image. In situations with normal labeled image (not a classified image), in 99.9% of the cases you'd have just one single binary image like I showed first.
See this example
0 0 1 0 2
0 1 1 0 2 Normal, labeled image.
0 1 1 0 2
0 0 1 2 2
0 1 1 2 2 Classified image, or highly unusual, labeled image.
0 1 1 0 2
Hi Image Analyst! I have come across a similar problem, which is a "Classified image" according to your comment above. Can you advise me on how to deal with such a situation? For example, in the matrix corresponding to the above "Classified image", I would like to have 4 labels.
Please let me know if I need to ask this as a new question, since this question is 7 years old. Thanks!
I have no idea what you want - no idea what "deal with" means to you. Start a new question and attach your image(s).

Sign in to comment.

More Answers (0)

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!