how to retrieve pixel values from bounding box of an image.

조회 수: 19 (최근 30일)
sami ullah
sami ullah 2020년 11월 4일
댓글: Ameer Hamza 2020년 11월 5일
Following is a code to create a bounding box of the detected face.
clear all
clc
faceDetector = vision.CascadeObjectDetector;
I = imread('visionteam.jpg'); % RGB IMage
figure
imshow(I)
title('Input Image')
bboxes = step(faceDetector, I);
IFaces = insertObjectAnnotation(I, 'Rectangle', bboxes, 'Face');
figure, imshow(IFaces), title('Detected faces');
--------------------------------------------------------------------
My question is:
How can I obtain pixel values inside this bounding box area?
Store the retrieved values in M by N by 3 matrix, after obtaining the pixel values under the bounding box area. How can it be done?

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 11월 4일
편집: Ameer Hamza 2020년 11월 4일
See imcrop(): https://www.mathworks.com/help/images/ref/imcrop.html. For example, add following lines at end of your code
faces = cell(1, size(bboxes,1));
for i=1:numel(faces)
faces{i} = imcrop(I, bboxes(i,:));
end
It will save each face in the cell array.
  댓글 수: 4
sami ullah
sami ullah 2020년 11월 5일
Thanks a lot Ameer Hamza
Ameer Hamza
Ameer Hamza 2020년 11월 5일
I am glad to be of help!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Feature Detection and Extraction에 대해 자세히 알아보기

제품


릴리스

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by