0
+---------------+
|               |                              
|  white        |          
|               |                                                      
+------+        |                 +---------------+
       |        |                 |               |
       |        |                 |   white       |
       +--------+                 |               |           
                                  |               |
                                  +---------------+


     +--------------------------+                                  black
     |                          |           
     |                          |
     |      white               |
     |                          |
     |                          |                                      
     +--------------------------+                   

How can I label and colorize the 3 shapes for a simple image (like above).

  • using connected component analysis with 8 neighborhood
  • the shapes are white colored and the outside is black
  • each of the shapes will get a color like blue, green, etc.
  • should be a simple code (with MATLAB) which processes the image pixel by pixel according to connected component analysis

Thank you for any help.

tewoos
  • 45
  • 2
  • 10
  • 1
    And what have you tried? Did you try google with the exact terms from your question? When I do I find a nice tutorial by The Mathworks on how to do exactly that. – Benoit_11 Dec 27 '15 at 19:17
  • I tried to find from google. There are some codes which colorizes the shapes but the code seems little complex for me. And I couldn't understand whether it uses CCA. I didn't code in MATLAB till now. So, I am new in MATLAB and trying to find some help. If you have a good link from google, please share with me. – tewoos Dec 27 '15 at 19:48
  • check [this](http://www.mathworks.com/help/images/labeling-and-measuring-objects-in-a-binary-image.html) out – Benoit_11 Dec 27 '15 at 20:31
  • The duplicate I have linked above performs CCA via Depth-First Search in MATLAB. Once you obtain a map of which pixels belong to which object, you can loop over each unique ID and colour the objects with whatever colour you desire. Good luck! – rayryeng Dec 27 '15 at 22:47
  • Thank you **Benoit_11** & **rayryeng**. – tewoos Dec 28 '15 at 14:30

0 Answers0