2016-04-07 22 views
-1
FDetect = vision.CascadeObjectDetector; 

%// Read the input image 

I = imread('face.jpg'); 

%// Returns Bounding Box values based on number of objects 
BB = step(FDetect,I); 

figure, 
imshow(I); 
hold on 
for i = 1:size(BB,1) 
    rectangle('Position',BB(i,:),'LineWidth',2.5,'LineStyle','','EdgeColor','r'); 
end 
title('Face Detection'); 
hold off; 

Filter:Gesichtserkennung und geben Filter

E = imerode(I,strel('square',5)); 

figure, imshow(E); 

Mein Problem ist, wie Filter geben nur IN Gesichtsbereich Rechteck.

enter image description here

Antwort

1

Sie wollen nur Region des Bildes zu extrahieren, die innerhalb der Begrenzungsrahmen ist, und dann imerode Betrieb gelten nur auf diesen Teil.

Die Begrenzungsbox hat die Form [x, y, Breite, Höhe]. Wir müssen das in Pixel umwandeln.

%// Ensure that we are working with integers. 
BB(k,:) = round(BB(k,:)); 

%// Sample all rows and columns within this bounding box 
rows = BB(k,2):sum(BB(k,[2 4])) 
cols = BB(k,1):sum(BB(k,[1 3])) 

%// Apply the imerode operation on just these pixels 
I(rows,cols) = imerode(I(rows,cols), strel('square', 5));