§
    fŠtj,  ã                   óf   — d dl Zd dlmZ ddlmZ ddlmZ g d¢Zd„ Zd„ Z	dd
„Z
dd„Zdd„Zdd„ZdS )é    N)Únormalize_axis_indexé   )Ú_ni_support)Ú	_nd_image)Úfourier_gaussianÚfourier_uniformÚfourier_ellipsoidÚfourier_shiftc                 ó  — | €v|j         j        t          j        t          j        t          j        fv r!t          j        |j        |j         ¬¦  «        } n¶t          j        |j        t          j        ¬¦  «        } n�t          | ¦  «        t          u r[| t          j        t          j        t          j        t          j        fvrt          d¦  «        ‚t          j        |j        | ¬¦  «        } n| j        |j        k    rt          d¦  «        ‚| S ©N©Údtypezoutput type not supportedzoutput shape not correct)
r   ÚtypeÚnpÚ	complex64Ú
complex128Úfloat32ÚzerosÚshapeÚfloat64ÚRuntimeError©ÚoutputÚinputs     úT/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/scipy/ndimage/_fourier.pyÚ_get_output_fourierr   (   sÖ   € Ø€~ØŒ;Ô¥¤­b¬m½R¼ZÐHÐHÐHÝ”X˜eœk°´Ð=Ñ=Ô=ˆFˆFå”X˜eœkµ´Ð<Ñ<Ô<ˆFˆFÝ	ˆf‰Œ�Ð	Ð	Ø�"œ,­¬Ýœ*¥b¤jð2ð 2ð 2åÐ:Ñ;Ô;Ð;Ý”˜%œ+¨VÐ4Ñ4Ô4ˆˆØ	Œ˜œÒ	$Ð	$ÝÐ5Ñ6Ô6Ð6Ø€Mó    c                 óÔ  — | €k|j         j        t          j        t          j        fv r!t          j        |j        |j         ¬¦  «        } n t          j        |j        t          j        ¬¦  «        } nzt          | ¦  «        t          u rE| t          j        t          j        fvrt          d¦  «        ‚t          j        |j        | ¬¦  «        } n| j        |j        k    rt          d¦  «        ‚| S r   )r   r   r   r   r   r   r   r   r   s     r   Ú_get_output_fourier_complexr   8   sÃ   € Ø€~ØŒ;Ô¥¤­b¬mÐ<Ð<Ð<Ý”X˜eœk°´Ð=Ñ=Ô=ˆFˆFå”X˜eœkµ´Ð?Ñ?Ô?ˆFˆFÝ	ˆf‰Œ�Ð	Ð	Ø�"œ,­¬Ð6Ð6Ð6ÝÐ:Ñ;Ô;Ð;Ý”˜%œ+¨VÐ4Ñ4Ô4ˆˆØ	Œ˜œÒ	$Ð	$ÝÐ5Ñ6Ô6Ð6Ø€Mr   éÿÿÿÿc                 ó^  — t          j        | ¦  «        } t          || ¦  «        }t          || j        ¦  «        }t          j        || j        ¦  «        }t          j        |t           j        ¬¦  «        }|j        j	        s| 
                    ¦   «         }t          j        | ||||d¦  «         |S )a  
    Multidimensional Gaussian fourier filter.

    The array is multiplied with the fourier transform of a Gaussian
    kernel.

    Parameters
    ----------
    input : array_like
        The input array.
    sigma : float or sequence
        The sigma of the Gaussian kernel. If a float, `sigma` is the same for
        all axes. If a sequence, `sigma` has to contain one value for each
        axis.
    n : int, optional
        If `n` is negative (default), then the input is assumed to be the
        result of a complex fft.
        If `n` is larger than or equal to zero, the input is assumed to be the
        result of a real fft, and `n` gives the length of the array before
        transformation along the real transform direction.
    axis : int, optional
        The axis of the real transform.
    output : ndarray, optional
        If given, the result of filtering the input is placed in this array.

    Returns
    -------
    fourier_gaussian : ndarray
        The filtered input.

    Examples
    --------
    >>> from scipy import ndimage, datasets
    >>> import numpy.fft
    >>> import matplotlib.pyplot as plt
    >>> fig, (ax1, ax2) = plt.subplots(1, 2)
    >>> plt.gray()  # show the filtered result in grayscale
    >>> ascent = datasets.ascent()
    >>> input_ = numpy.fft.fft2(ascent)
    >>> result = ndimage.fourier_gaussian(input_, sigma=4)
    >>> result = numpy.fft.ifft2(result)
    >>> ax1.imshow(ascent)
    >>> ax2.imshow(result.real)  # the imaginary part is an artifact
    >>> plt.show()
    r   r   ©r   Úasarrayr   r   Úndimr   Ú_normalize_sequencer   ÚflagsÚ
contiguousÚcopyr   Úfourier_filter)r   ÚsigmaÚnÚaxisr   Úsigmass         r   r   r   G   s˜   € õ\ ŒJ�uÑÔ€EÝ  ¨Ñ/Ô/€FÝ  e¤jÑ1Ô1€DÝÔ,¨U°E´JÑ?Ô?€FÝŒZ˜¥b¤jÐ1Ñ1Ô1€FØŒ<Ô"ð Ø—’‘”ˆåÔ˜U F¨A¨t°V¸QÑ?Ô?Ð?Ø€Mr   c                 ó^  — t          j        | ¦  «        } t          || ¦  «        }t          || j        ¦  «        }t          j        || j        ¦  «        }t          j        |t           j        ¬¦  «        }|j        j	        s| 
                    ¦   «         }t          j        | ||||d¦  «         |S )a  
    Multidimensional uniform fourier filter.

    The array is multiplied with the Fourier transform of a box of given
    size.

    Parameters
    ----------
    input : array_like
        The input array.
    size : float or sequence
        The size of the box used for filtering.
        If a float, `size` is the same for all axes. If a sequence, `size` has
        to contain one value for each axis.
    n : int, optional
        If `n` is negative (default), then the input is assumed to be the
        result of a complex fft.
        If `n` is larger than or equal to zero, the input is assumed to be the
        result of a real fft, and `n` gives the length of the array before
        transformation along the real transform direction.
    axis : int, optional
        The axis of the real transform.
    output : ndarray, optional
        If given, the result of filtering the input is placed in this array.

    Returns
    -------
    fourier_uniform : ndarray
        The filtered input.

    Examples
    --------
    >>> from scipy import ndimage, datasets
    >>> import numpy.fft
    >>> import matplotlib.pyplot as plt
    >>> fig, (ax1, ax2) = plt.subplots(1, 2)
    >>> plt.gray()  # show the filtered result in grayscale
    >>> ascent = datasets.ascent()
    >>> input_ = numpy.fft.fft2(ascent)
    >>> result = ndimage.fourier_uniform(input_, size=20)
    >>> result = numpy.fft.ifft2(result)
    >>> ax1.imshow(ascent)
    >>> ax2.imshow(result.real)  # the imaginary part is an artifact
    >>> plt.show()
    r   r   r"   ©r   Úsizer+   r,   r   Úsizess         r   r   r   �   s˜   € õ\ ŒJ�uÑÔ€EÝ  ¨Ñ/Ô/€FÝ  e¤jÑ1Ô1€DÝÔ+¨D°%´*Ñ=Ô=€EÝŒJ�u¥B¤JÐ/Ñ/Ô/€EØŒ;Ô!ð Ø—
’
‘”ˆÝÔ˜U E¨1¨d°F¸AÑ>Ô>Ð>Ø€Mr   c                 ó¬  — t          j        | ¦  «        } | j        dk    rt          d¦  «        ‚t	          || ¦  «        }|j        dk    r|S t          || j        ¦  «        }t          j        || j        ¦  «        }t          j        |t           j	        ¬¦  «        }|j
        j        s|                     ¦   «         }t          j        | ||||d¦  «         |S )ah  
    Multidimensional ellipsoid Fourier filter.

    The array is multiplied with the fourier transform of an ellipsoid of
    given sizes.

    Parameters
    ----------
    input : array_like
        The input array.
    size : float or sequence
        The size of the box used for filtering.
        If a float, `size` is the same for all axes. If a sequence, `size` has
        to contain one value for each axis.
    n : int, optional
        If `n` is negative (default), then the input is assumed to be the
        result of a complex fft.
        If `n` is larger than or equal to zero, the input is assumed to be the
        result of a real fft, and `n` gives the length of the array before
        transformation along the real transform direction.
    axis : int, optional
        The axis of the real transform.
    output : ndarray, optional
        If given, the result of filtering the input is placed in this array.

    Returns
    -------
    fourier_ellipsoid : ndarray
        The filtered input.

    Notes
    -----
    This function is implemented for arrays of rank 1, 2, or 3.

    Examples
    --------
    >>> from scipy import ndimage, datasets
    >>> import numpy.fft
    >>> import matplotlib.pyplot as plt
    >>> fig, (ax1, ax2) = plt.subplots(1, 2)
    >>> plt.gray()  # show the filtered result in grayscale
    >>> ascent = datasets.ascent()
    >>> input_ = numpy.fft.fft2(ascent)
    >>> result = ndimage.fourier_ellipsoid(input_, size=20)
    >>> result = numpy.fft.ifft2(result)
    >>> ax1.imshow(ascent)
    >>> ax2.imshow(result.real)  # the imaginary part is an artifact
    >>> plt.show()
    é   z'Only 1d, 2d and 3d inputs are supportedr   r   é   )r   r#   r$   ÚNotImplementedErrorr   r0   r   r   r%   r   r&   r'   r(   r   r)   r/   s         r   r	   r	   º   sÆ   € õd ŒJ�uÑÔ€EØ„z�A‚~€~Ý!Ð"KÑLÔLÐLÝ  ¨Ñ/Ô/€FØ„{�aÒÐð ˆÝ  e¤jÑ1Ô1€DÝÔ+¨D°%´*Ñ=Ô=€EÝŒJ�u¥B¤JÐ/Ñ/Ô/€EØŒ;Ô!ð Ø—
’
‘”ˆÝÔ˜U E¨1¨d°F¸AÑ>Ô>Ð>Ø€Mr   c                 ó\  — t          j        | ¦  «        } t          || ¦  «        }t          || j        ¦  «        }t          j        || j        ¦  «        }t          j        |t           j        ¬¦  «        }|j        j	        s| 
                    ¦   «         }t          j        | ||||¦  «         |S )aü  
    Multidimensional Fourier shift filter.

    The array is multiplied with the Fourier transform of a shift operation.

    Parameters
    ----------
    input : array_like
        The input array.
    shift : float or sequence
        The size of the box used for filtering.
        If a float, `shift` is the same for all axes. If a sequence, `shift`
        has to contain one value for each axis.
    n : int, optional
        If `n` is negative (default), then the input is assumed to be the
        result of a complex fft.
        If `n` is larger than or equal to zero, the input is assumed to be the
        result of a real fft, and `n` gives the length of the array before
        transformation along the real transform direction.
    axis : int, optional
        The axis of the real transform.
    output : ndarray, optional
        If given, the result of shifting the input is placed in this array.

    Returns
    -------
    fourier_shift : ndarray
        The shifted input.

    Examples
    --------
    >>> from scipy import ndimage, datasets
    >>> import matplotlib.pyplot as plt
    >>> import numpy.fft
    >>> fig, (ax1, ax2) = plt.subplots(1, 2)
    >>> plt.gray()  # show the filtered result in grayscale
    >>> ascent = datasets.ascent()
    >>> input_ = numpy.fft.fft2(ascent)
    >>> result = ndimage.fourier_shift(input_, shift=200)
    >>> result = numpy.fft.ifft2(result)
    >>> ax1.imshow(ascent)
    >>> ax2.imshow(result.real)  # the imaginary part is an artifact
    >>> plt.show()
    r   )r   r#   r   r   r$   r   r%   r   r&   r'   r(   r   r
   )r   Úshiftr+   r,   r   Úshiftss         r   r
   r
   ý   s–   € õZ ŒJ�uÑÔ€EÝ(¨°Ñ7Ô7€FÝ  e¤jÑ1Ô1€DÝÔ,¨U°E´JÑ?Ô?€FÝŒZ˜¥b¤jÐ1Ñ1Ô1€FØŒ<Ô"ð Ø—’‘”ˆÝÔ˜E 6¨1¨d°FÑ;Ô;Ð;Ø€Mr   )r    r    N)Únumpyr   Úscipy._lib._utilr   Ú r   r   Ú__all__r   r   r   r   r	   r
   © r   r   ú<module>r>      sÙ   ðð> Ð Ð Ð Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð ðð ð €ðð ð ð ð ð ð7ð 7ð 7ð 7ðt6ð 6ð 6ð 6ðr@ð @ð @ð @ðF5ð 5ð 5ð 5ð 5ð 5r   