
    9i-4                         S SK r S SKrSSKJr  SSKJr  SSKJr  S r	S r
      SSS	.S
 jjr      SSS	.S jjr       SSS	.S jjr       SSS	.S jjrg)    N   )gaussian)convert_to_float   )resizec           	          [         R                  " U 5      nUb"  X@R                  -  nU4U R                  S-
  -  nOSn[        U UUUUUS9  U$ )z?Return image with each channel smoothed by the Gaussian filter.Nr   )sigmaoutmodecvalchannel_axis)np
empty_likendimr   )imager	   r   r   r   smootheds         Z/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/skimage/transform/pyramids.py_smoothr   
   s^    }}U#H #jj0EJJN+! O    c                 &    U S::  a  [        S5      eg )Nr   z#scale factor must be greater than 1)
ValueError)factors    r   _check_factorr       s    {>?? r   r   c          	      4  ^^ [        T5        [        X5      n Tb9  TU R                  -  m[        UU4S j[	        U R
                  5       5       5      nO[        U4S jU R
                   5       5      nUc  ST-  S-  n[        XXET5      n	[        XX4USS9n
U
$ )a  Smooth and then downsample image.

Parameters
----------
image : ndarray
    Input image.
downscale : float, optional
    Downscale factor.
sigma : float, optional
    Sigma for Gaussian filter. Default is `2 * downscale / 6.0` which
    corresponds to a filter mask twice the size of the scale factor that
    covers more than 99% of the Gaussian distribution.
order : int, optional
    Order of splines used in interpolation of downsampling. See
    `skimage.transform.warp` for detail.
mode : {'reflect', 'constant', 'edge', 'symmetric', 'wrap'}, optional
    The mode parameter determines how the array borders are handled, where
    cval is the value when mode is equal to 'constant'.
cval : float, optional
    Value to fill past edges of input if mode is 'constant'.
preserve_range : bool, optional
    Whether to keep the original range of values. Otherwise, the input
    image is converted according to the conventions of `img_as_float`.
    Also see https://scikit-image.org/docs/dev/user_guide/data_types.html
channel_axis : int or None, optional
    If None, the image is assumed to be a grayscale (single channel) image.
    Otherwise, this parameter indicates which axis of the array corresponds
    to channels.

    .. versionadded:: 0.19
       ``channel_axis`` was added in 0.19.

Returns
-------
out : array
    Smoothed and downsampled float image.

References
----------
.. [1] http://persci.mit.edu/pub_pdfs/pyramid83.pdf

c              3   |   >#    U  H1  u  pUT:w  a"  [         R                  " U[        T5      -  5      OUv   M3     g 7fNmathceilfloat.0axdr   	downscales      r   	<genexpr>!pyramid_reduce.<locals>.<genexpr>_   s9      
/ 02\/ADIIa%	**+qH/   9<c              3   h   >#    U  H'  n[         R                  " U[        T5      -  5      v   M)     g 7fr   r   r#   r%   r&   s     r   r'   r(   d   s'     O;a$))Ai(8$899;   /2r         @Forderr   r   anti_aliasing)r   r   r   tuple	enumerateshaper   r   )r   r&   r	   r/   r   r   preserve_ranger   	out_shaper   r
   s    `     `   r   pyramid_reducer6   %   s    j )U3E#ejj0 
"5;;/
 
	
 O5;;OO	}I#uT>H
5$eC Jr   c          	      4  ^^ [        T5        [        X5      n Tb9  TU R                  -  m[        UU4S j[	        U R
                  5       5       5      nO[        U4S jU R
                   5       5      nUc  ST-  S-  n[        XX4USS9n	[        XXET5      n
U
$ )a  Upsample and then smooth image.

Parameters
----------
image : ndarray
    Input image.
upscale : float, optional
    Upscale factor.
sigma : float, optional
    Sigma for Gaussian filter. Default is `2 * upscale / 6.0` which
    corresponds to a filter mask twice the size of the scale factor that
    covers more than 99% of the Gaussian distribution.
order : int, optional
    Order of splines used in interpolation of upsampling. See
    `skimage.transform.warp` for detail.
mode : {'reflect', 'constant', 'edge', 'symmetric', 'wrap'}, optional
    The mode parameter determines how the array borders are handled, where
    cval is the value when mode is equal to 'constant'.
cval : float, optional
    Value to fill past edges of input if mode is 'constant'.
preserve_range : bool, optional
    Whether to keep the original range of values. Otherwise, the input
    image is converted according to the conventions of `img_as_float`.
    Also see https://scikit-image.org/docs/dev/user_guide/data_types.html
channel_axis : int or None, optional
    If None, the image is assumed to be a grayscale (single channel) image.
    Otherwise, this parameter indicates which axis of the array corresponds
    to channels.

    .. versionadded:: 0.19
       ``channel_axis`` was added in 0.19.

Returns
-------
out : array
    Upsampled and smoothed float image.

References
----------
.. [1] http://persci.mit.edu/pub_pdfs/pyramid83.pdf

c              3   j   >#    U  H(  u  pUT:w  a  [         R                  " TU-  5      OUv   M*     g 7fr   r   r    )r#   r$   r%   r   upscales      r   r'   !pyramid_expand.<locals>.<genexpr>   s3      
/ ')L&8DIIgk"a?/s   03c              3   V   >#    U  H  n[         R                  " TU-  5      v   M      g 7fr   r9   )r#   r%   r:   s     r   r'   r;      s!     F+Q$))GaK00+s   &)r   r-   Fr.   )r   r   r   r1   r2   r3   r   r   )r   r:   r	   r/   r   r   r4   r   r5   resizedr
   s    `     `   r   pyramid_expandr>   r   s    j 'U3E#ejj0 
"5;;/
 
	
 F%++FF	}Gc!t5G '$l
;CJr   c          
   #      #    [        U5        [        X5      n Sn	U R                  n
U nU v   X:w  a6  U	S-  n	[        UUUUUUUS9nU
nUnUR                  n
X:X  a  gUv   X:w  a  M5  gg7f)a  Yield images of the Gaussian pyramid formed by the input image.

Recursively applies the `pyramid_reduce` function to the image, and yields
the downscaled images.

Note that the first image of the pyramid will be the original, unscaled
image. The total number of images is `max_layer + 1`. In case all layers
are computed, the last image is either a one-pixel image or the image where
the reduction does not change its shape.

Parameters
----------
image : ndarray
    Input image.
max_layer : int, optional
    Number of layers for the pyramid. 0th layer is the original image.
    Default is -1 which builds all possible layers.
downscale : float, optional
    Downscale factor.
sigma : float, optional
    Sigma for Gaussian filter. Default is `2 * downscale / 6.0` which
    corresponds to a filter mask twice the size of the scale factor that
    covers more than 99% of the Gaussian distribution.
order : int, optional
    Order of splines used in interpolation of downsampling. See
    `skimage.transform.warp` for detail.
mode : {'reflect', 'constant', 'edge', 'symmetric', 'wrap'}, optional
    The mode parameter determines how the array borders are handled, where
    cval is the value when mode is equal to 'constant'.
cval : float, optional
    Value to fill past edges of input if mode is 'constant'.
preserve_range : bool, optional
    Whether to keep the original range of values. Otherwise, the input
    image is converted according to the conventions of `img_as_float`.
    Also see https://scikit-image.org/docs/dev/user_guide/data_types.html
channel_axis : int or None, optional
    If None, the image is assumed to be a grayscale (single channel) image.
    Otherwise, this parameter indicates which axis of the array corresponds
    to channels.

    .. versionadded:: 0.19
       ``channel_axis`` was added in 0.19.

Returns
-------
pyramid : generator
    Generator yielding pyramid layers as float images.

References
----------
.. [1] http://persci.mit.edu/pub_pdfs/pyramid83.pdf

r   r   r   N)r   r   r3   r6   )r   	max_layerr&   r	   r/   r   r   r4   r   layercurrent_shapeprev_layer_imagelayer_image
prev_shapes                 r   pyramid_gaussianrF      s     B ) U3EEKKM
K 

$%
 #
&#)) &+ 
s   A#A)'A)c          
   #   j  ^^#    [        T5        [        X5      n Uc  ST-  S-  nU R                  n	[        XXVT5      n
X
-
  v   Tb7  TU R                  -  m[        U	5      nUR                  T5        [        U5      nOU	nUS:X  a4  [        R                  " [        R                  " [        U5      T5      5      n[        U5       Hh  nTb   [        UU4S j[        U	5       5       5      nO[        U4S jU	 5       5      n[        U
UUUUSS9n[        XXVT5      n
UR                  n	X-
  v   Mj     g7f)	a  Yield images of the laplacian pyramid formed by the input image.

Each layer contains the difference between the downsampled and the
downsampled, smoothed image::

    layer = resize(prev_layer) - smooth(resize(prev_layer))

Note that the first image of the pyramid will be the difference between the
original, unscaled image and its smoothed version. The total number of
images is `max_layer + 1`. In case all layers are computed, the last image
is either a one-pixel image or the image where the reduction does not
change its shape.

Parameters
----------
image : ndarray
    Input image.
max_layer : int, optional
    Number of layers for the pyramid. 0th layer is the original image.
    Default is -1 which builds all possible layers.
downscale : float, optional
    Downscale factor.
sigma : float, optional
    Sigma for Gaussian filter. Default is `2 * downscale / 6.0` which
    corresponds to a filter mask twice the size of the scale factor that
    covers more than 99% of the Gaussian distribution.
order : int, optional
    Order of splines used in interpolation of downsampling. See
    `skimage.transform.warp` for detail.
mode : {'reflect', 'constant', 'edge', 'symmetric', 'wrap'}, optional
    The mode parameter determines how the array borders are handled, where
    cval is the value when mode is equal to 'constant'.
cval : float, optional
    Value to fill past edges of input if mode is 'constant'.
preserve_range : bool, optional
    Whether to keep the original range of values. Otherwise, the input
    image is converted according to the conventions of `img_as_float`.
    Also see https://scikit-image.org/docs/dev/user_guide/data_types.html
channel_axis : int or None, optional
    If None, the image is assumed to be a grayscale (single channel) image.
    Otherwise, this parameter indicates which axis of the array corresponds
    to channels.

    .. versionadded:: 0.19
       ``channel_axis`` was added in 0.19.

Returns
-------
pyramid : generator
    Generator yielding pyramid layers as float images.

References
----------
.. [1] http://persci.mit.edu/pub_pdfs/pyramid83.pdf
.. [2] http://sepwww.stanford.edu/data/media/public/sep/morgan/texturematch/paper_html/node3.html

Nr   r-   c              3   |   >#    U  H1  u  pUT:w  a"  [         R                  " U[        T5      -  5      OUv   M3     g 7fr   r   r"   s      r   r'   $pyramid_laplacian.<locals>.<genexpr>  s9      5EB 463E		!eI../1L5r)   c              3   h   >#    U  H'  n[         R                  " U[        T5      -  5      v   M)     g 7fr   r   r+   s     r   r'   rJ     s'     U}!diiE),<(<==}r,   Fr.   )r   r   r3   r   r   listpopr1   r   r    logmaxranger2   r   )r   r@   r&   r	   r/   r   r   r4   r   rB   smoothed_imageshape_without_channelsrA   r5   resized_images     `     `      r   pyramid_laplacianrT   $  s:    J ) U3E}I#KKMU4|DN

  #ejj0!%m!4""<0!&'=!>!. BIIdhhs+A'BINO	y!# &}5 I
 U}UUI
 !t<P%++,,) "s   D/D3)r   Nr   reflectr   F)rH   r   Nr   rU   r   F)r   numpyr   _shared.filtersr   _shared.utilsr   _warpsr   r   r   r6   r>   rF   rT    r   r   <module>r[      s      & , ,@ 

		
J J^ 

		
I I\ 

		
c cP 

		
t- t-r   