I am trying to create the segmentation mask for each red color boundary. Input image has 4 polygons with a red color boundary. I want to mark each polygon segment with different colors as shown in the output. Please help me with this.
CodePudding user response:
Why can't you simply scan through the image and do the following:
- execute
CodePudding user response:
- take red channel only. consider as single-channel grayscale/binary.
- invert. areas become white. borders become black.
- connected components labeling (of the white areas).
connectedComponentsis the API
To paint a picture where each area has a color, use numpy operations (mask indexing, assignment) to construct that picture from the labels map returned by
connectedComponents.


