clc;
clear;
faceDetector = vision.CascadeObjectDetector();
file_path='E:/database/Normal/';
path_list=dir(strcat(file_path,'*.tif'));
img_num=length(path_list);
if img_num>0
for j=1:img_num
image_name=path_list(j).name;
I=imread(strcat(file_path,image_name));
bbox=step(faceDetector,I);
faceOut = insertObjectAnnotation(I,'rectangle',bbox,'face');
faceout1=imcrop(I,bbox);
faceout2=imresize(faceout1,[80,80]);
imwrite(faceout2,strcat(num2str(j+1004),'.tif'));
end
end
人脸的图像的切割以检测为前提,以下是切割过程总结
python实现:
#!/usr/bin/python
# -*- coding: utf-8 -*-
#!/usr/bin/python
import dlib # 人脸识别库
import numpy as np #数据处理库
import cv2 # 图像处理库
detector = dlib.get_frontal_face_detector()#与人脸检测相同&