How to crop a detected object in an image using the Object bounding box using matlab

Hey. I am new to image processing. I want to extract the detected image area as a new image. I detect the eye area of ​​the face using the method caseCadeObjectDetector. Now I would like to know how to extract the detected area of ​​the image. Here is what I did.

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

I draw this bounding box using a method insertObjectAnnotation. It depicts a line above the eye. But I want to crop this eye as a new image. bbox has a 1x4 matrix containing x , y, height, width. Can anybody help me? I am using MATLAB r2013a.

+3
source share
1 answer

- bbox [x, y, height, width], :

subImage = i(bbox(1):bbox(1)+bbox(3), bbox(2):bbox(2)+bbox(4), :);

PS bbox [x, y, width, height], imcrop:

subImage = imcrop(i, bbox);
+4

All Articles