|No such thing as a small change|
PDL: Looking for efficient way to extract sub-images, by finding bounding boxes of "objects"by vr (Friar)
|on Nov 18, 2016 at 11:35 UTC||Need Help??|
vr has asked for the
wisdom of the Perl Monks concerning the following question:
For a kind of OCR-ish task, I need to find bboxes of all "objects" in 2D image. Then I can use slicing to extract sub-images as virtual piddles.
Suppose there's an image with 3 "objects":
That's quite fast. And then:
That gives bboxes in data structure I want. But it's too slow - tens of seconds for some-megapixel image and hundred of "objects", before I even began to use these data.
I wonder if it can be faster. Maybe to skip creating of a mask ($s == $_), i.e. hundred of them. Plus, the whichND gives a piddle of _all_ indexes - when all I want is a bounding box. Maybe there's a way to e.g. efficiently collapse a dimension looking for required index in segmented image ($s, above). I feel I'm missing something obvious. Any ideas?