menpo/image/masked.py
def build_mask_around_landmarks(self, patch_size, group=None, label=None):
        r"""
        Restricts this images mask to be patches around each landmark in
        the chosen landmark group. This is useful for visualizing patch
        based methods.

        Parameters
        ----------
        patch_shape : `tuple`
            The size of the patch. Any floating point values are rounded up
            to the nearest integer.
        group : `str`, 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.
        label: `str`, optional
            The label of of the landmark manager that you wish to use. If no
            label is passed, the convex hull of all landmarks is used.
        """
        pc = self.landmarks[group][label]
        patch_size = np.ceil(patch_size)
        patch_half_size = patch_size / 2
        mask = np.zeros(self.shape)
        max_x = self.shape[0] - 1
        max_y = self.shape[1] - 1

        for i, point in enumerate(pc.points):
            start = np.floor(point - patch_half_size).astype(int)
            finish = np.floor(point + patch_half_size).astype(int)
            x, y = np.mgrid[start[0]:finish[0], start[1]:finish[1]]
            # deal with boundary cases
            x[x > max_x] = max_x
            y[y > max_y] = max_y
            x[x < 0] = 0
            y[y < 0] = 0
            mask[x.flatten(), y.flatten()] = True

        self.mask = BooleanImage(mask)
r"""
        Restricts this images mask to be patches around each landmark in
        the chosen landmark group. This is useful for visualizing patch
        based methods.

        Parameters
        ----------
        patch_shape : `tuple`
            The size of the patch. Any floating point values are rounded up
            to the nearest integer.
        group : `str`, 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.
        label: `str`, optional
            The label of of the landmark manager that you wish to use. If no
            label is passed, the convex hull of all landmarks is used.
        
r"""
Restricts this images mask to be patches around each landmark in
the chosen landmark group. This is useful for visualizing patch
based methods.

Parameters

patch_shape : `tuple`
The size of the patch. Any floating point values are rounded up
to the nearest integer.
group : `str`, 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.
label: `str`, optional
The label of of the landmark manager that you wish to use. If no
label is passed, the convex hull of all landmarks is used.
r " " " Restricts this images mask to be patches around each landmark in the chosen landmark group . This is useful for visualizing patch based methods . Parameters patch_shape : ` tuple ` The size of the patch . Any floating point values are rounded up to the nearest integer . group : ` str ` 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 . label : ` str ` optional The label of of the landmark manager that you wish to use . If no label is passed the convex hull of all landmarks is used .
def build_mask_around_landmarks(self, patch_size, group=None, label=None):
        pc = self.landmarks[group][label]
        patch_size = np.ceil(patch_size)
        patch_half_size = patch_size / 2
        mask = np.zeros(self.shape)
        max_x = self.shape[0] - 1
        max_y = self.shape[1] - 1
        for i, point in enumerate(pc.points):
            start = np.floor(point - patch_half_size).astype(int)
            finish = np.floor(point + patch_half_size).astype(int)
            x, y = np.mgrid[start[0]:finish[0], start[1]:finish[1]]
            x[x > max_x] = max_x
            y[y > max_y] = max_y
            x[x < 0] = 0
            y[y < 0] = 0
            mask[x.flatten(), y.flatten()] = True
        self.mask = BooleanImage(mask)
def build_mask_around_landmarks ( self , patch_size , group = None , label = None ) : pc = self . landmarks [ group ] [ label ] patch_size = np . ceil ( patch_size ) patch_half_size = patch_size / 2 mask = np . zeros ( self . shape ) max_x = self . shape [ 0 ] - 1 max_y = self . shape [ 1 ] - 1 for i , point in enumerate ( pc . points ) : start = np . floor ( point - patch_half_size ) . astype ( int ) finish = np . floor ( point + patch_half_size ) . astype ( int ) x , y = np . mgrid [ start [ 0 ] : finish [ 0 ] , start [ 1 ] : finish [ 1 ] ] x [ x > max_x ] = max_x y [ y > max_y ] = max_y x [ x < 0 ] = 0 y [ y < 0 ] = 0 mask [ x . flatten ( ) , y . flatten ( ) ] = True self . mask = BooleanImage ( mask )
r"""
Restricts this images mask to be patches around each landmark in
the chosen landmark group.
r " " " Restricts this images mask to be patches around each landmark in the chosen landmark group .
r"""
        Restricts this images mask to be patches around each landmark in
        the chosen landmark group. This is useful for visualizing patch
        based methods.

        Parameters
        ----------
        patch_shape : `tuple`
            The size of the patch. Any floating point values are rounded up
            to the nearest integer.
        group : `str`, 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.
        label: `str`, optional
            The label of of the landmark manager that you wish to use. If no
            label is passed, the convex hull of all landmarks is used.
        """ # deal with boundary cases
self
patch_size
group
label