Find Image components using python/PIL
<p>Is there a function in PIL/Pillow that for a grayscale image, will separate the image into sub images containing the components that make up the original image? For example, a png grayscale image with a set of blocks in them. Here, the images types always have high contrast to the background.</p>

<p>I don't want to use openCV, I just need some general blob detection, and was hoping Pillow/PIL might have something that does that already.</p>

<p>Yes, it is possible. You can use <code>edge</code> detection algorithms in PIL.
Sample code:</p>

<pre><code>from PIL import Image, ImageFilter
image = Image.open('/tmp/sample.png').convert('RGB')
image = image.filter(ImageFilter.FIND_EDGES)
image.save('/tmp/output.png') 
</code></pre>

<p>sample.png :</p>

<p><a href="http://i.stack.imgur.com/tL5pc.png" rel="nofollow"><img src="http://i.stack.imgur.com/tL5pc.png" alt="enter image description here"></a></p>

<p>output.png:</p>

<p><a href="http://i.stack.imgur.com/JIHem.png" rel="nofollow"><img src="http://i.stack.imgur.com/JIHem.png" alt="enter image description here"></a></p>

python pillow