Save face delimited - Matlab

Hello people. I used the algorithm below to detect the face of the people, but would like to save the cropped face, how can I do this?
A = imread ('marcelo.jpg');
FaceDetector = vision.CascadeObjectDetector();
BBOX = step(FaceDetector, A);
B = insertObjectAnnotation (A, 'rectangle', BBOX, 'Face'); imshow(B), title('Detected Faces');

 Accepted Answer

Try putting (the badly-named) A and the bounding box into imcrop():
croppedImage = imcrop(A, BBOX);

2 Comments

Great worked thank you very much.
Would you kindly help me with another question?
I performed the delimitation of the face with his help, found the position of the eyes and through the position of the eyes aligned the image with the component imrotate.
I need now to delimit the image a little above the line of the eyes and also to delimit in the horizontal because when the alignment was done, the image was left unadjusted. Follows an image represented. Can you help me? Thanks in advance
rosto = (imrotate(rosto,(180/pi)*atan((BBREye(2)-BBLEye(2))/(BBREye(1)-BBLEye(1))))); imwrite(rosto, strcat('rotacionada.jpg'));
imrotate has options where you can expand the canvass, or crop the image if the corners go outside the canvass. Perhaps you want the cropping option instead of the expand the canvass option.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!