7
$\begingroup$

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.

enter image description here

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

enter image description here

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?

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Niki Estner Aug 9 '13 at 16:49
  • 1
    $\begingroup$ 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 :) $\endgroup$ – Abid Rahman K Aug 9 '13 at 17:25
  • 1
    $\begingroup$ I'd highly recommend shooting the photos without flash, under uniform illumination. You can use opening morphological operation, it corresponds to erosion and dilation. $\endgroup$ – Andrey Rubshtein Aug 9 '13 at 18:46
1
$\begingroup$

I agree with Abid Rahman K, however eroding only would result in shape shrinkage. To only get rid of the gap, Abid Rahman suggests a watershed based approach, but for a faster and easier method you might try:

  • Erode the regions
  • Apply connected component labeling.
  • Dilate the regions back.

This way you will have almost the same shape (with some artifacts arising due to morphology) but you will surely end up with single connected components.

Watersheds and distance transform are also powerful and might be good choices if you have a lot of overlap.

$\endgroup$

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.