def visualize_mean_face(x_mean, size, new_dims):
"""Rearrange the data in the mean face to a 2D array
- Organize the contents in the mean face vector to a 2D array.
- Normalize this image.
- Resize it to match the new dimensions parameter
Args:
x_mean (numpy.array): Mean face values.
size (tuple): x_mean 2D dimensions
new_dims (tuple): Output array dimensions
Returns:
numpy.array: Mean face uint8 2D array.
"""
#new_size = size+(1,)
#vis_mean = x_mean.reshape(size).astype(np.uint8)
vis_mean = x_mean.reshape(size).astype(int)
vis_mean = cv2.resize(vis_mean, new_dims, interpolation = cv2.INTER_CUBIC)
return vis_mean
After change the datatype, I found I can't resize the image, and the error says:"cv2.error: ......\opencv-2.4.13.2\modules\imgproc\src\imgwarp.cpp:2114: error: (-215) func != 0 in function cv::resize"
After a long time search, I found that datatype has a problem, I should change the float to np.uint8, instead of pure int.