【问题标题】:how to crop the detected object in image with Object's bounding box using matlab如何使用matlab使用对象的边界框裁剪图像中检测到的对象
【发布时间】:2014-03-23 01:00:32
【问题描述】:

嗨。我是图像处理的新手。我想将检测到的图像区域提取为新图像。我使用caseCadeObjectDetector 方法检测面部的眼睛区域。现在我想知道,如何提取检测到的图像区域。这就是我所做的。

i=imread('test.jpg');
Eyedetect =  vision.CascadeObjectDetector('RightEye','MergeThreshold',24);
bbox=step(Eyedetect,i);

我使用insertObjectAnnotation 方法绘制该边界框。它在眼睛上绘制线。但我想将那只眼睛裁剪为新图像。 bbox 是 1x4 矩阵,包含x , y, height, width。 有谁能够帮我?我正在使用 MATLAB r2013a。

【问题讨论】:

    标签: image matlab image-processing crop matlab-cvst


    【解决方案1】:

    要提取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);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-08-02
      • 1970-01-01
      • 2014-07-20
      • 1970-01-01
      • 2014-08-02
      • 2020-08-21
      • 2021-08-12
      相关资源
      最近更新 更多