# Jigsaw puzzle: isolating the pieces (separating “stuck” blobs)

I'm new to image processing, and I'm trying to get my feet wet. I have taken a picture of some jigsaw puzzle pieces and I want to isolate the pieces.

I am using the Python SimpleCV library to do this, and so far I've managed to get pretty decent results using findBlobs(), hueDistance(), and drawMinRect(). Here's what I've got so far

Pretty good, honestly. The only place it's wrong is with those two pieces touching slightly to the right of center.

I tried dilating the image, but that seems to exacerbate the problem. How can I "shrink" these blobs to eliminate the overlap?

• I'm assuming that at some point (after hueDistance?) you have an image where the background is dark and the foreground is bright, right? (Or the other way round.) If you take this image and dilate it, the bright areas will grow. If you erode it, the bright areas will shrink. – Niki Estner Aug 9 '13 at 16:49
• Hi, you need to erode the picture. It will reduce the size of the puzzles, but also removes the joints. If you want the objects to be in its original size, you can use watershed algorithm. And next time try to detach all puzzles before taking photo :) – Abid Rahman K Aug 9 '13 at 17:25
• I'd highly recommend shooting the photos without flash, under uniform illumination. You can use opening morphological operation, it corresponds to erosion and dilation. – Andrey Rubshtein Aug 9 '13 at 18:46