<p>I had to solve a similar problem recently that involved counting the number of indentations on blobs within in an image (basically, the connected components returned by bwconncomp).  The method I used was to look at curvature changes along the boundary calculated via the FFT.  In your case, the red blobs would have a large number of curvature variations, whereas the black regions would not.  It's a pretty easy calculation and relatively fast.  The code is on github here:</p>

<p><a href="https://github.com/mjsottile/blobdents" rel="nofollow">https://github.com/mjsottile/blobdents</a></p>

<p>The file of interest is src/countindents.m.  A short description of the approach is here:</p>

<p><a href="http://arxiv.org/abs/1501.07692" rel="nofollow">http://arxiv.org/abs/1501.07692</a></p>
Is there any regularity-detection tool for regions inside an image?
<p>I'm working on MATLAB on some regions inside an image. I'm at a point in which I would like to be able to separate regions which exhibit some kind of regularity (e.g., being circle-ish or square-ish) from regions which does not resemble any known figure and which for my application are mere noise. I'll illustrate this using a descriptive MS Paint image:</p>

<p><img src="https://i.stack.imgur.com/UEYtK.png" alt="enter image description here"></p>

<p>Is there any tool that, <em>most of the times</em> (or even less, I know this can't be 100/100) will recognize the red thing as being <em>different</em>?</p>

<p>I'll deal with many shapes in a single image, so I don't mind if I carry on some red monsters along the way, as long as the majority of them is kicked out. Of course I know the indices of these regions, so I can manipulate them in MATLAB.</p>

<p>Many algorithms come to mind, e.g., getting the boundary and checking for its regularity/the number of times it changes curvature/..., checking for variations in vertical length through different columns (nearly 0 for the linear feature, really high for the red stuff), ...</p>

<p>However I was hoping in some help from a tool out there. It doesn't matter if this tool won't cover all cases (for example, will kick out circles), I've been very broad to get the maximum number of inputs from you guys - any tool will be inspiring and helpful (and, however, we can't expect a perfect answer for the deeper question - recognizing regular shapes - which seems more like a AI field of research). I also think that, while being broad, this is totally non-subjective so should fit in SO. Thank you.</p>

<p><strong>Side note 1</strong>: I'll deal mostly with elongated, extended features like the top-right one, so circles are not that relevant.</p>

<p><strong>Side note 2</strong>: To be 100% clear, I would need something (be it an already existant tool, or some ideas pointed out by you) that acts on the indices of the shapes, in terms of rows-columns into the original image, or on the boundary of the shape itself.</p>

<p><strong>Side note 3</strong>: Apart from tools/suggestions/ideas, you are welcomed to write down some lines of code ;) I'm getting the regions as <em>connected components</em> from <code>bwconncomp</code>.</p>