嗨。我是图像处理的新手。我想将检测到的图像区域提取为新图像。我使用 caseCadeObjectDetector
方法检测脸部的眼睛区域。现在我想知道如何提取检测到的图像区域。这是我所做的。
i=imread('test.jpg');
Eyedetect = vision.CascadeObjectDetector('RightEye','MergeThreshold',24);
bbox=step(Eyedetect,i);
我使用 insertObjectAnnotation
方法绘制边界框。它绘制了眼睛上方的线。但我想将那只眼睛裁剪为新图像。 bbox 是一个 1x4 矩阵,包含 x, y, height, width
。
有谁能够帮助我?我正在使用 MATLAB r2013a。
最佳答案
要使用 bbox
以 [x, y, height, width]
格式提取子图像,您可以使用:
subImage = i(bbox(1):bbox(1)+bbox(3), bbox(2):bbox(2)+bbox(4), :);
P.S.如果bbox
格式为[x, y, width, height]
,你可以直接调用imcrop
:
subImage = imcrop(i, bbox);
关于image - 如何使用matlab使用对象的边界框裁剪图像中检测到的对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21935691/