Beispiel #1
0
    def convolved_array_from_array_2d_and_mask(self, array_2d, mask):
        """
        Convolve an array with this Kernel

        Parameters
        ----------
        image : ndarray
            An array representing the image the Kernel is convolved with.

        Returns
        -------
        convolved_image : ndarray
            An array representing the image after convolution.

        Raises
        ------
        KernelException if either Kernel psf dimension is odd
        """

        if self.mask.shape[0] % 2 == 0 or self.mask.shape[1] % 2 == 0:
            raise exc.KernelException("Kernel Kernel must be odd")

        mask_sub_1 = mask.mapping.mask_sub_1

        return mask_sub_1.mapping.array_stored_1d_from_array_2d(
            scipy.signal.convolve2d(array_2d, self.in_2d, mode="same"))
Beispiel #2
0
    def convolved_array_from_array_and_mask(self, array, mask):
        """
        Convolve an array with this Kernel2D

        Parameters
        ----------
        image : np.ndarray
            An array representing the image the Kernel2D is convolved with.

        Returns
        -------
        convolved_image : np.ndarray
            An array representing the image after convolution.

        Raises
        ------
        KernelException if either Kernel2D psf dimension is odd
        """

        if self.mask.shape[0] % 2 == 0 or self.mask.shape[1] % 2 == 0:
            raise exc.KernelException("Kernel2D Kernel2D must be odd")

        convolved_array_2d = scipy.signal.convolve2d(array,
                                                     self.native,
                                                     mode="same")

        convolved_array_1d = array_2d_util.array_2d_slim_from(
            mask_2d=mask, array_2d_native=convolved_array_2d, sub_size=1)

        return array_2d.Array2D(array=convolved_array_1d, mask=mask.mask_sub_1)