Extract connected/neighboring regions in an image via a specific input colored pixel

Viewed 122

I have an image - enter image description here

I would like to get an output image that just has the highlighted red portions.

Output image - enter image description here

How would I do this ?

What I am trying to do is isolate underline/strikethrough text decorations so that I can extract the text along with the text decoration information.

What I had in mind -

  • Remove all pixels (convert to white) that are not connected to a red pixel (connected to red pixel via some other non-white pixel also counts). I tried using connected components but it seems I need to pass in a binary image and this approach failed.
  • Using a sliding window to iterate through the pixels and if the sliding window has a red pixel, don't do anything, if it doesn't, turn all the pixel within the window - white. The sliding window size will be adjusted based on trial and error.
0 Answers
Related