本文整理汇总了Python中menpo.transform.Translation.range方法的典型用法代码示例。如果您正苦于以下问题:Python Translation.range方法的具体用法?Python Translation.range怎么用?Python Translation.range使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类menpo.transform.Translation
的用法示例。
在下文中一共展示了Translation.range方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _build_reference_frame
# 需要导入模块: from menpo.transform import Translation [as 别名]
# 或者: from menpo.transform.Translation import range [as 别名]
def _build_reference_frame(landmarks, boundary=3, group='source'):
# translate landmarks to the origin
minimum = landmarks.bounds(boundary=boundary)[0]
landmarks = Translation(-minimum).apply(landmarks)
resolution = landmarks.range(boundary=boundary)
reference_frame = MaskedImage.blank(resolution)
reference_frame.landmarks[group] = landmarks
return reference_frame
示例2: init_from_pointcloud
# 需要导入模块: from menpo.transform import Translation [as 别名]
# 或者: from menpo.transform.Translation import range [as 别名]
def init_from_pointcloud(cls, pointcloud, group=None, boundary=0,
constrain=True, fill=True):
r"""
Create an Image that is big enough to contain the given pointcloud.
The pointcloud will be translated to the origin and then translated
according to its bounds in order to fit inside the new image.
An optional boundary can be provided in order to increase the space
around the boundary of the pointcloud. The boundary will be added
to *all sides of the image* and so a boundary of 5 provides 10 pixels
of boundary total for each dimension.
By default, the mask will be constrained to the convex hull of the
provided pointcloud.
Parameters
----------
pointcloud : :map:`PointCloud`
Pointcloud to place inside the newly created image.
group : `str`, optional
If ``None``, the pointcloud will only be used to create the image.
If a `str` then the pointcloud will be attached as a landmark
group to the image, with the given string as key.
boundary : `float`
A optional padding distance that is added to the pointcloud bounds.
Default is ``0``, meaning the max/min of tightest possible
containing image is returned.
fill : `int`, optional
The value to fill all pixels with.
constrain : `bool`, optional
If ``True``, the ``True`` values will be image will be constrained
to the convex hull of the provided pointcloud. If ``False``,
the mask will be the value of ``fill``.
Returns
-------
image : :map:`MaskedImage`
A new image with the same size as the given pointcloud, optionally
with the pointcloud attached as landmarks and the mask constrained
to the convex hull of the pointcloud.
"""
# Translate pointcloud to the origin
minimum = pointcloud.bounds(boundary=boundary)[0]
origin_pc = Translation(-minimum).apply(pointcloud)
image_shape = origin_pc.range(boundary=boundary)
new_image = cls.init_blank(image_shape, fill=fill)
if constrain:
new_image = new_image.constrain_to_pointcloud(origin_pc)
if group is not None:
new_image.landmarks[group] = origin_pc
return new_image