
    (ph,                     l    S SK rS SKJr  SSKJr  SSKJr  / SQrS rS r	SS	 jr
SS
 jrSS jrSS jrg)    N)normalize_axis_index   )_ni_support)	_nd_image)fourier_gaussianfourier_uniformfourier_ellipsoidfourier_shiftc                    U c  UR                   R                  [        R                  [        R                  [        R
                  4;   a+  [        R                  " UR                  UR                   S9n U $ [        R                  " UR                  [        R                  S9n  U $ [        U 5      [        L an  U [        R                  [        R                  [        R
                  [        R                  4;  a  [        S5      e[        R                  " UR                  U S9n U $ U R                  UR                  :w  a  [        S5      eU $ Ndtypezoutput type not supportedzoutput shape not correct)
r   typenp	complex64
complex128float32zerosshapefloat64RuntimeErroroutputinputs     I/var/www/html/venv/lib/python3.13/site-packages/scipy/ndimage/_fourier.py_get_output_fourierr   (   s    ~;;bmmRZZHHXXekk=F M XXekk<F M 
f	",,**bjj2 2:;;%++V4 M 
	$566M    c                 @   U c  UR                   R                  [        R                  [        R                  4;   a+  [        R
                  " UR                  UR                   S9n U $ [        R
                  " UR                  [        R                  S9n  U $ [        U 5      [        L aP  U [        R                  [        R                  4;  a  [        S5      e[        R
                  " UR                  U S9n U $ U R                  UR                  :w  a  [        S5      eU $ r   )r   r   r   r   r   r   r   r   r   s     r   _get_output_fourier_complexr   8   s    ~;;bmm<<XXekk=F M XXekk?F M 
f	",,66:;;%++V4 M 
	$566Mr   c                    [         R                  " U 5      n [        X@5      n[        X0R                  5      n[
        R                  " XR                  5      n[         R                  " U[         R                  S9nUR                  R                  (       d  UR                  5       n[        R                  " XX#US5        U$ )ac  
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    \ JJuE /Fjj1D,,UJJ?FZZbjj1F<<""UAVQ?Mr   c                    [         R                  " U 5      n [        X@5      n[        X0R                  5      n[
        R                  " XR                  5      n[         R                  " U[         R                  S9nUR                  R                  (       d  UR                  5       n[        R                  " XX#US5        U$ )ae  
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    \ JJuE /Fjj1D++D**=EJJuBJJ/E;;!!

U1FA>Mr   c                    [         R                  " U 5      n U R                  S:  a  [        S5      e[	        X@5      nUR
                  S:X  a  U$ [        X0R                  5      n[        R                  " XR                  5      n[         R                  " U[         R                  S9nUR                  R                  (       d  UR                  5       n[        R                  " XX#US5        U$ )a  
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   r/   r   r   r$   r   r%   r&   r'   r   r(   r.   s         r   r	   r	      s    d JJuEzzA~!"KLL /F{{a jj1D++D**=EJJuBJJ/E;;!!

U1FA>Mr   c                 ~   [         R                  " U 5      n [        X@5      n[        X0R                  5      n[
        R                  " XR                  5      n[         R                  " U[         R                  S9nUR                  R                  (       d  UR                  5       n[        R                  " XX#U5        U$ )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 JJuE(7Fjj1D,,UJJ?FZZbjj1F<<""E1F;Mr   )r8   N)numpyr   scipy._lib._utilr    r   r   __all__r   r   r   r   r	   r
    r   r   <module>r>      s<   >  1   7t6r@F5r   