Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
PPT:
thought:
First converted to YCbCr image, characterized by the use of human skin. CR property.
Color conversion to 255, non-color of 0. This creates a binary image.
There will be a small noise, small objects directly corrosion corroded thousand million.
Reuse find split extraction. You can separate out the person's face it.
Code:
clc,clear,close all;
f=imread('h1.jpg');figure,imshow(f);
fycbcr=rgb2ycbcr(f);
cr = fycbcr(:,:,3);figure,imshow(cr);
cr(cr>140&cr<160)=255;
cr(cr~=255)=0;
figure,imshow(cr);
ba=bwareaopen(cr,500);
figure,imshow(ba);
[r,c]=find(ba);
rr=f(min(r):max(r),min(c):max(c),:);
figure,imshow(rr);
result:
step:
Original:
Extraction YCBCR CR:
CR color range becomes 255, the other becomes 0:
result:
OK