def rescale_to_reference_shape(self, reference_shape, group=None, label='all', interpolator='scipy', round='ceil', **kwargs): r""" Return a copy of this image, rescaled so that the scale of a particular group of landmarks matches the scale of the passed reference landmarks. Parameters ---------- reference_shape: :class:`menpo.shape.pointcloud` The reference shape to which the landmarks scale will be matched against. group : string, Optional The key of the landmark set that should be used. If None, and if there is only one set of landmarks, this set will be used. Default: None label: string, Optional The label of of the landmark manager that you wish to use. If 'all' all landmarks in the group are used. Default: 'all' interpolator : 'scipy' or 'c', optional The interpolator that should be used to perform the warp. round: {'ceil', 'floor', 'round'} Rounding function to be applied to floating point shapes. Default: 'ceil' kwargs : dict Passed through to the interpolator. See `menpo.interpolation` for details. Returns ------- rescaled_image : type(self) A copy of this image, rescaled. """ pc = self.landmarks[group][label].lms scale = UniformScale.align(pc, reference_shape).as_vector() return self.rescale(scale, interpolator=interpolator, round=round, **kwargs)
def __init__(self, shape_models, appearance_models, transform_cls, feature_type, reference_shape, downscale, patch_size, interpolator): self.shape_models = shape_models self.appearance_models = appearance_models self.transform_cls = transform_cls self.feature_type = feature_type self.reference_shape = reference_shape self.downscale = downscale self.patch_size = patch_size self.interpolator = interpolator if len(appearance_models) > 1: difference = UniformScale.align( appearance_models[0].mean.landmarks['source'].lms, appearance_models[1].mean.landmarks['source'].lms).as_vector() if difference == 1: self.scaled_reference_frames = False else: self.scaled_reference_frames = True else: self.downscale = None self.scaled_reference_frames = None