Home > Software design >  Get the segmentation mask for the bounded polygon
Get the segmentation mask for the bounded polygon

Time:01-09

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.

Input Image Input image

Output Image Output Image

CodePudding user response:

Why can't you simply scan through the image and do the following:

  1. execute enter image description here

    CodePudding user response:

    1. take red channel only. consider as single-channel grayscale/binary.
    2. invert. areas become white. borders become black.
    3. connected components labeling (of the white areas). connectedComponents is 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.

  •  Tags:  
  • Related