Easy way to get rid of noise in a hand drawing I would like to take a user's hand drawn input, and filter out "noise", aka small sketches or blobs, where the user might have screwed up and accidentally touched his hand to the drawing device, or something similar.

I'm using Imagick, a PHP wrapper that wraps an image processing library that does everything short of actual, high-level blob detection.  So I'm free to use convolution, erosion, dilation, and a slew of other image processing tools.  I can't write blob detection in the high level PHP code because it's too slow.  And before I go down a path of writing the C code using ImageMagick's API, and wrapping it in PHP, I was wondering if there's some sort of "trick" that I can do to accomplish my objective.

For instance, my initial thought would be to do an erosion on the image (in normal situations, when I think of removing noise from an image, I think to erode then dilate).  But since ALL the lines in the image are just a few pixels wide, everything would disappear.  Then I was considering some sort of blur so the longer lines would end up with higher intensities, then I could just threshold out the lower ones.  But again, in the context of lines, I'm not sure how well that works.

I'll attach an image of increasing "blobs".  I would consider the first 4 left ones as blobs that I want to remove, but then keep the 5th, the line, and the box.
You can use opening on your image http://php.net/manual/en/imagick.morphology.php with a kernel big enough to erode the small objects