get_sub_crop_size

lib.align.aligned_utils.get_sub_crop_size(source_centering: CenteringType, target_centering: CenteringType, size: int, coverage_ratio: float = 1.0) int

Obtain the size of a cropped face from an aligned image.

Given an image of a certain dimensions, returns the dimensions of the sub-crop within that image for the requested centering at the requested coverage ratio

Notes

“legacy” places the nose in the center of the image (the original method for aligning). “face” aligns for the nose to be in the center of the face (top to bottom) but the center of the skull for left to right. “head” places the center in the middle of the skull in 3D space.

The ROI in relation to the source image is calculated by rounding the padding of one side to the nearest integer then applying this padding to the center of the crop, to ensure that any dimensions always have an even number of pixels.

Parameters:
  • source_centering (CenteringType) – The centering that the original image is aligned at

  • target_centering (CenteringType) – The centering that the sub-crop size should be obtained for

  • size (int) – The size of the source image to obtain the cropped size for

  • coverage_ratio (float) – The coverage ratio to be applied to the target image. Default: 1.0

Return type:

The pixel size of a sub-crop image from a full head aligned image with the given coverage ratio