ROI processing


Is it possible to apply some operations in the ROI after you have the image from img = sensor.snapshot()?

I mean : I draw a rectangle inside my img , and i only want to apply filters for everything inside the rectangle (ROI).

Thank you!

The best way to do this is to use the copy() method with an ROI to pull out the image patch. Given memory limits this is a challenge if the patch is large.

To make this easier I’m redoing the copy operation so you can target larger allocated frame buffers to allow for large images.

Otherwise, the only way to do this is to create a pixel mask for the image that has 1 pixels where you want to operate. Binary image functionality hasn’t been fully released yet however. But, basically do this…

bimg = img.to_bitmap(copy=True).clear().draw_rect(x, y, w, h, fill=True, color=1)
img.mean(2, mask=bimg)

Binary images are quite small so they might make the most sense. Since it’s a mask you can select whatever pixels you want.

Thank you! I will give this a try.