def preprocess_faces(images, n_components='default', resize_shape='default'):
""" Notes: Images are all square, but not the same size. We resize all the
images to be the same sized square, thereby preserving the
aspect ratios.
"""
for img in images:
assert img.shape[0] == img.shape[1]
if resize_shape == 'default':
resize_shape = get_smallest_shape(images)
preprocessed_images = []
for img in images:
prepped_img = imresize(img, resize_shape).astype(float)
prepped_img = prepped_img.flatten()
preprocessed_images.append(prepped_img)
preprocessed = get_principal_components(preprocessed_images, n_components)
return preprocessed
评论列表
文章目录