Marek Woźniak
Marek Woźniak

Reputation: 1776

Processing image and find outer edge. Find an algorithm

I have problem with one from steps which i have to do. Most important problem. I have an image, for example: enter image description here

The second step's to select part of image: enter image description here

Ok. If i have this image in cache, which selected area:

enter image description here

Early steps i have done. Problem is with the last step, which task is to select only (exactly outer) border area. Here's example how it should looks:

enter image description here

My ask's to what algorithm or steps i have to do for the last effect. It's feasible for any images? My prefered language's C#/C/JS but if somebody know the knowledge about solution it will be nice! I had find some algorithm for detect edge, but not for outer edge.

Upvotes: 3

Views: 163

Answers (1)

dfens
dfens

Reputation: 5515

Maybe try the following:

  • pick some random 10 pixels from borders of selection (it is important that those are borders)
  • get average rgb of those pixels
  • get MAX = max color distance between pixels
  • perform white flood fill with tolerance = k*MAX, starting from one of edge pixels

this way you should be able to flood fill only the gray background in selection

Upvotes: 1

Related Questions