Matlab图像中对象的边界框 [英] Bounding box of an object in an image Matlab

查看:221
本文介绍了Matlab图像中对象的边界框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获取图像中对象的边界框位置(x,y,宽度和高度)并将其保存到文本文件中.如下图所示.所以,如果有人可以请指教. 可以在此处找到该图像

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

推荐答案

假设您已使用imread读取了图像,则此方法应该有效:

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的边界框的左上角,其宽度和高度以[corner_x corner_y width height]格式存储.

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].

这篇关于Matlab图像中对象的边界框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆