4
$\begingroup$

I'm designing software that produces images such as the following:

snippet

Regions of interest are circumscribed by red pixels. I am interested in extracting the fully-enclosed pixel regions. Ultimately, I would like to calculate the approximate center, width, and height of the regions. Ideally, I would even like to eliminate interior loops--that is, only preserve the largest enclosing body of a region (a "region" being an isolated pixel group).

I have experience implementing search algorithms, so my first instinct is to traverse the edges until a loop is detected (arrival at the start); however, I recognize the potential for multiple solutions--alternate, valid loop possibilities--and then I would require a way to decide between them. Perhaps the one that is longer or encloses the greatest number of pixels.

$\endgroup$
  • $\begingroup$ Do you have a larger image? Maybe make the small thumbnail in your question a link to a large image, with higher resolution? $\endgroup$ – D.W. Apr 2 '15 at 6:12
  • $\begingroup$ What are you given? You are given the red outlines, or you want to compute them? $\endgroup$ – D.W. Apr 2 '15 at 6:14
  • $\begingroup$ I was given an image and computed the red pixels. The image now links to a larger resolution image. $\endgroup$ – EntangledLoops Apr 3 '15 at 19:06
  • $\begingroup$ this doesnt sound too hard & sounds like there are algorithms for what you want (& might know of some) but it seems not clearly defined/ ambiguous/ interpreted, needs better detail. eg "I am interested in extracting the fully-enclosed pixel regions." $\endgroup$ – vzn Apr 3 '15 at 20:01
3
$\begingroup$

If you are given the red pixels, try decomposing the pixels into strongly connected components (SCC), where two pixels are in the same SCC if they are adjacent and neither one is red. Then each SCC represents a region. This is a standard technique in computer vision. Another way to think about this: try using flood fill from each possible starting point.

If you're not given the red pixels: you have a blob finding / segmentation kind of problem. Try looking at existing methods for block detection. You should also look at the watershed algorithm for image segmentation. There are also methods based upon max flow (i.e., minimum graph cuts).

Doing some searches using these keywords will probably find you many more resources.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks! That's the simple solution I wanted. All I could think of was from the red pixel's perspective. $\endgroup$ – EntangledLoops Apr 3 '15 at 19:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.