Ask Your Question
0

Blob detection to produce cropped sub images?

asked 2012-01-23 15:39:17 -0500

anonymous user

Anonymous

Is it possible to use detected blobs within an image to then crop the original image's pixels into separate png files? I've tried using pilImage to produce a brand new image file, but have had little success. The detected blobs only contain x,y tuples, and I am finding it very difficult to understand how to convert these into numpy arrays to feed into the pilImage's putdata method.

I've come across this post on how to create a circular (or really any arbitrary shaped) mask and then operate on that region of interest (http://nashruddin.com/OpenCVRegionofInterest(ROI) ) but my python skills are not nearly up to snuff to adapt this for my own use.

SimpleCV has turned out to do a ton right out of the box, and I thought I would check in to see if there was a neat way to do this simply via available APIs.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2012-01-23 15:39:55 -0500

xamox gravatar image

Yes, it's quite easy actually, here is the code:

c = Camera()
img = c.getImage()
blobs = img.findBlobs()
counter = 0

for b in blobs:
  save_path = "img-" + str(counter) + ".png"
  img.crop(b).save(save_path)
  counter += 1

At the moment we don't really have ROI's in SimpleCV, as you can pass a feature to the crop function and it will return the cropped image. We are still in process of how we want to do it, mainly we are considering letting ROI's retain information or context across frames, but probably will be architecture in 2.0.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2012-01-23 15:39:17 -0500

Seen: 1,573 times

Last updated: Jan 23 '12