Multiple rectangular regions can be specified in roi
operation of cv-calc
(like the draw
operation), so that:
- everything outside these regions in the input images is set to zero, or
- these regions are cropped out of input images into separate images (the arguments prefixed to input will be removed).
All images in the input stream must have same number of regions. Any region with zero width or height (e.g. 0,0,0,0) will be ignored and, if needed, can be used so that all images have same number of regions.
If all the bounding boxes for an image have zero area, then the whole image will be set to zero
To try following examples, download this image.
> # mask in 2 rectangles > cv-cat --file 20180101T000000.jpg \ | csv-paste "value=800,500,1600,1700,2500,750,3100,1700;binary=8ui" "-;binary=t,3ui,s[21723870]" \ | cv-calc roi --fields=rectangles,t,rows,cols,type --binary=8ui,t,3ui --rectangles="2,weight=5" \ | csv-bin-cut --binary=8ui,t,3ui,s[21723870] --fields 9-13 \ > masked.bin > # crop out 2 rectangles ( csv-bin-cut not needed in this case ) > cv-cat --file 20180101T000000.jpg \ | csv-paste "value=800,500,1600,1700,2500,750,3100,1700;binary=8ui" "-;binary=t,3ui,s[21723870]" \ | cv-calc roi --crop --fields=rectangles,t,rows,cols,type --binary=8ui,t,3ui --rectangles="2,weight=5" \ > cropped.bin
2 Comments
Vsevolod Vlaskine
Aneel Rathore; if one image in the stream has 5 bounding boxes and the next 3 bounding boxes, how should it be expressed?
Matthew Imhoff
A related question: is it worth making this consistent with cv-calc draw operation (at least for rectangles)?