How to crop detected face part?

3 ビュー (過去 30 日間)
Sana Ullah
Sana Ullah 2019 年 12 月 3 日
コメント済み: Sana Ullah 2019 年 12 月 3 日
a=imread('C:\Users\SanaUllah\Documents\MATLAB\face.jpg');
a=imresize(a,1);
subplot(3,3,1);
imshow(a);
detector=vision.CascadeObjectDetector('mouth');
detector.MergeThreshold=60;
boundingbox=step(detector,a);
out=insertObjectAnnotation(a,'rectangle',boundingbox,'mouth Detected','LineWidth',3,'TextColor','black');
subplot(3,3,2);
imshow(out)
  1 件のコメント
Sana Ullah
Sana Ullah 2019 年 12 月 3 日
image.jpeg
sorry i havent shown the detected mouth picture but
through above programming i have detected the mouth but now i have no idea how to crop the detected mouth.
please someone help me in this .

サインインしてコメントする。

採用された回答

Image Analyst
Image Analyst 2019 年 12 月 3 日
Try this:
rgbImage = imread('face.jpeg');
rgbImage = imresize(rgbImage,1);
subplot(2, 3, 1);
imshow(rgbImage);
axis('on', 'image');
drawnow;
detector=vision.CascadeObjectDetector('mouth');
detector.MergeThreshold=60;
allBoundingBoxes=step(detector,rgbImage)
out = insertObjectAnnotation(rgbImage,'rectangle',allBoundingBoxes,'mouth Detected','LineWidth',3,'TextColor','black');
subplot(2, 3, 2);
imshow(out)
axis('on', 'image');
% Crop out each bounding box to a new image.
for k = 1 : size(allBoundingBoxes, 1)
% Crop the image.
thisBoundingBox = allBoundingBoxes(k, :);
croppedImage = imcrop(rgbImage, thisBoundingBox);
% Display it
subplot(2, 3, k+2);
imshow(croppedImage)
axis('on', 'image');
end
0000 Screenshot.png
  1 件のコメント
Sana Ullah
Sana Ullah 2019 年 12 月 3 日
Ohh God this Answer is perfect ?. I have seen many of your answers on other problems. I was just waiting for you to guide me on this problem . Thank you so much Sir.

サインインしてコメントする。

その他の回答 (2 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 12 月 3 日
Please see my this answer, it may help
  1 件のコメント
Sana Ullah
Sana Ullah 2019 年 12 月 3 日
thank you sir that was very helpfull.

サインインしてコメントする。


Philippe Lebel
Philippe Lebel 2019 年 12 月 3 日
編集済み: Philippe Lebel 2019 年 12 月 3 日
RGB Images are 3D matrices with dimenions = (resolution_x, resolution_y, 3)
I suppose the bounding box contains the face.
Try this:
my_face = a(boundingbox(1):boundingbox(1)+boundingbox(3),boundingbox(2):boundingbox(2)+boundingbox(4), : )

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by