Pergunta

I want to get the object's bounding box positions (x, y, width and height) in the image and save it to a text file. As shown in the below image. So if anyone could please advise. The image can be found here enter image description here

Foi útil?

Solução

Assuming you have read the image using imread, this should work:

bwImage=~im2bw(img,0.98);  %making gray pixels white and (almost) white pixels black
bndBox=regionprops(bwImage,'BoundingBox');

bndBox will have top-left corner of the bounding box and its width and height stored in the format [corner_x corner_y width height].

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top