Esempio n. 1
0
def gradient_xy(image):
    # Compute the gradient of the image
    grad = fast_gradient(image)

    # Slice off the gradient for X and Y separately
    grad_y = Image(grad.pixels[:image.n_channels])
    grad_x = Image(grad.pixels[image.n_channels:])

    return grad_x, grad_y
Esempio n. 2
0
    def gradient(self, image):
        # Compute the gradient of the image
        grad = fast_gradient(image)

        # Create gradient image for X and Y
        grad_y = Image(grad.pixels[: self.n_channels])
        grad_x = Image(grad.pixels[self.n_channels :])

        return grad_x, grad_y
Esempio n. 3
0
    def gradient(self, image):
        # Compute the gradient of the image
        grad = fast_gradient(image)

        # Create gradient image for X and Y
        grad_y = Image(grad.pixels[:self.n_channels])
        grad_x = Image(grad.pixels[self.n_channels:])

        return grad_x, grad_y
Esempio n. 4
0
    def gradient(self, image):
        r"""
        Function that computes the gradient of the image.

        Parameters
        ----------
        image : :map:`Image`
            The input image.

        Returns
        -------
        gradient : `ndarray`
            The computed gradient.
        """
        pixels = image.pixels
        nabla = fast_gradient(pixels.reshape((-1, ) + self.patch_shape))
        # remove 1st dimension gradient which corresponds to the gradient
        # between parts
        return nabla.reshape((2, ) + pixels.shape)
Esempio n. 5
0
    def gradient(self, image):
        r"""
        Function that computes the gradient of the image.

        Parameters
        ----------
        image : :map:`Image`
            The input image.

        Returns
        -------
        gradient : `ndarray`
            The computed gradient.
        """
        pixels = image.pixels
        nabla = fast_gradient(pixels.reshape((-1,) + self.patch_shape))
        # remove 1st dimension gradient which corresponds to the gradient
        # between parts
        return nabla.reshape((2,) + pixels.shape)
Esempio n. 6
0
 def gradient(self, image):
     g = fast_gradient(image.pixels.reshape(
         (-1,) + self.algorithm.appearance_model.mean().shape[-2:]))
     return g.reshape((2,) + image.pixels.shape)
Esempio n. 7
0
 def gradient(self, image):
     return fast_gradient(image).set_boundary_pixels().as_vector().reshape((2, image.n_channels, -1))
Esempio n. 8
0
 def gradient(self, img):
     nabla = fast_gradient(img)
     nabla.set_boundary_pixels()
     return nabla.as_vector().reshape((2, img.n_channels, -1))
Esempio n. 9
0
 def gradient(self, image):
     pixels = image.pixels
     nabla = fast_gradient(pixels.reshape((-1,) + self.patch_shape))
     # remove 1st dimension gradient which corresponds to the gradient
     # between parts
     return nabla.reshape((2,) + pixels.shape)