Exemple #1
0
    def set_target(self, target):
        if target.n_points < self.target.n_points:

            if target.n_points < self.n_landmarks:
                target = PointCloud(target.points[:self.n_align_lms])
                target = np.dot(np.dot(target.as_vector(), self.pinv_va), self.W)
            else:
                target = PointCloud(target.points[:self.n_landmarks])
                target = np.dot(np.dot(target.as_vector(), self.pinv_v), self.W)

            target = PointCloud(np.reshape(target, (-1, self.n_dims)))

        OrthoPDM.set_target(self, target)
def mean_pointcloud(pointclouds):
    r"""
    Compute the mean of a `list` of :map:`PointCloud` or subclass objects.
    The list is assumed to be homogeneous i.e all elements of the list are
    assumed to belong to the same point cloud subclass just as all elements
    are also assumed to have the same number of points and represent
    semantically equivalent point clouds.

    Parameters
    ----------
    pointclouds: `list` of :map:`PointCloud` or subclass
        List of point cloud or subclass objects from which we want to compute
        the mean.

    Returns
    -------
    mean_pointcloud : :map:`PointCloud` or subclass
        The mean point cloud or subclass.
    """
    # make a temporary PointCloud (with copy=False for low overhead)
    tmp_pc = PointCloud(sum(pc.points
                            for pc in pointclouds) / len(pointclouds),
                        copy=False)
    # use the type of the first element in the list to rebuild from the vector
    return pointclouds[0].from_vector(tmp_pc.as_vector())
def test_pointcloud_flatten_rebuild():
    points = np.array([[1, 2, 3], [1, 1, 1]])
    pc = PointCloud(points)
    flattened = pc.as_vector()
    new_pc = pc.from_vector(flattened)
    assert (np.all(new_pc.n_dims == pc.n_dims))
    assert (np.all(new_pc.n_points == pc.n_points))
    assert (np.all(pc.points == new_pc.points))
Exemple #4
0
def test_pointcloud_flatten_rebuild():
    points = np.array([[1, 2, 3], [1, 1, 1]])
    pc = PointCloud(points)
    flattened = pc.as_vector()
    new_pc = pc.from_vector(flattened)
    assert np.all(new_pc.n_dims == pc.n_dims)
    assert np.all(new_pc.n_points == pc.n_points)
    assert np.all(pc.points == new_pc.points)
Exemple #5
0
    def sparse_target(self):
        r"""
        The current sparse `menpo.shape.PointCloud` that this object produces.

        :type: `menpo.shape.PointCloud`
        """
        sparse_target = PointCloud(self.target.points[:self.n_landmarks])
        return self._sparse_instance.from_vector(sparse_target.as_vector())
def mean_pointcloud(pointclouds):
    r"""
    Compute the mean of a `list` of :map:`PointCloud` or subclass objects.
    The list is assumed to be homogeneous i.e all elements of the list are
    assumed to belong to the same point cloud subclass just as all elements
    are also assumed to have the same number of points and represent
    semantically equivalent point clouds.

    Parameters
    ----------
    pointclouds: `list` of :map:`PointCloud` or subclass
        List of point cloud or subclass objects from which we want to compute
        the mean.

    Returns
    -------
    mean_pointcloud : :map:`PointCloud` or subclass
        The mean point cloud or subclass.
    """
    # make a temporary PointCloud (with copy=False for low overhead)
    tmp_pc = PointCloud(sum(pc.points for pc in pointclouds) /
                        len(pointclouds), copy=False)
    # use the type of the first element in the list to rebuild from the vector
    return pointclouds[0].from_vector(tmp_pc.as_vector())
Exemple #7
0
 def sparse_target(self):
     sparse_target = PointCloud(self.target.points[:self.n_landmarks])
     return self._sparse_instance.from_vector(sparse_target.as_vector())
Exemple #8
0
 def sparse_target(self):
     sparse_target = PointCloud(self.target.points[:self.n_landmarks])
     return self._sparse_instance.from_vector(sparse_target.as_vector())