BoundingBox Matlab [英] BoundingBox Matlab

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

问题描述

我有一幅图像,我想使用MATLAB的BoundingBox从同一区域获取每个区域的区域,这是我使用BoundingBox的示例:

I have an image where I want to get region per region from the same using BoundingBox on MATLAB, this is the example where I use BoundingBox:

Ic=regionprops(logical(I3),'BoundingBox');

在I3是我想要获取每个区域的区域然后显示每个区域的区域的图像的情况下,我对BoundingBox的独特了解是,在我的情况下,Ic是变量,它们从I3图像保存区域那是103个字段或区域,但是我不知道如何在不同的图中显示每个区域的区域,我知道这样做,MATLAB会显示103个数字,对此我没有任何问题.

Where I3 is the image that I want to get region per region and then display region per region, the unique thing that I know about BoundingBox is that in my case, Ic is the variable where they saved the regions from the I3 Image that are 103 field or region, but I don't know how to display region per region in different figure, I understand that doing that, MATLAB will show 103 figures, I dont have any problem with that.

推荐答案

使用regionprops查找BoundingBox的结果是由[x, y, width, height]定义的矩形.您可以使用这些结果通过内置的 rectangle 函数.

The result of finding the BoundingBox with regionprops is a rectangle defined by [x, y, width, height]. You can use these results to plot a rectangle using the built-in rectangle function.

如果要将它们全部放在同一轴上,可以执行以下操作:

If you wanted to put them all on the same axis you could do:

fig = figure;
him = imshow(I3);
hold on;

colors = hsv(numel(Ic));

% Now plot all the rectangles
for k = 1:numel(Ic)
    rectangle('Position', Ic(k).BoundingBox, 'EdgeColor', colors(k,:));
end

如果您想为每个边界框结果添加一个新图形:

And if you want a new figure for every bounding box result:

% Anonymous function to help with the conversion from rect
rect2rng = @(pos,len)ceil(pos):(ceil(pos)+len-1);

for k = 1:numel(Ic)
    rect = Ic(k).BoundingBox;
    subImage = I3(rect2rng(rect(2), rect(4)), rect2rng(rect(1), rect(3)));
    fig = figure;
    him = imshow(subImage);
    title(sprintf('Bounding Box #%d', k)); 
end

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

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