
    9iz                         S SK Jr  S SK r S SKrS SKJrJr  S SKJr  SSK	J
r
  \
(       d  S SKJr  OS SKJr   " S	 S
\5      rS r SS jr       SS jr       SSS.S jjrg)    )combinations_with_replacementN)filtersfeature)img_as_float32   )is_wasm)ThreadPoolExecutor)AbstractContextManagerc                   &    \ rS rSrS rS rS rSrg)PoolExecutor   c                     g N )self___s      _/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/skimage/feature/_basic_features.py__init__PoolExecutor.__init__           c                     g r   r   )r   exc_typeexc_valexc_tbs       r   __exit__PoolExecutor.__exit__   r   r   c                     [        X5      $ r   )map)r   fn	iterabless      r   r    PoolExecutor.map   s    r%%r   r   N)__name__
__module____qualname____firstlineno__r   r   r    __static_attributes__r   r   r   r   r      s    			&r   r   c           	          [        [        U R                  5      S5       VVs/ s H1  u  p[        R                  " [        R                  " U 5      U   US9PM3     nnn[
        R                  " U5      nU$ s  snnf )Nr   axis)r   rangendimnpgradientr   hessian_matrix_eigvals)gaussian_filteredax0ax1H_elemseigvalss        r   _texture_filterr6      sp     6e<M<R<R6SUVWWHC 	BKK 1237cBW   ,,W5GNs   8A6c                     Sn[         R                  " XSS9nU(       a  XV4-  nU(       a  U[         R                  " U5      4-  nU(       a  U/ [        U5      Q7-  nU$ )Nr   F)sigmapreserve_range)r   gaussiansobelr6   )imgr8   	intensityedgestextureresultsr1   s          r   )_singlescale_basic_features_singlechannelrA   "   sb     G((%P''GMM"34669_%6799Nr   c           	        ^ ^^^ [         R                  " [        T 5      5      m Uc9  [        [         R                  " U5      [         R                  " U5      -
  S-   5      n[         R
                  " [         R                  " U5      [         R                  " U5      USSS9n[        US9 n	[        U	R                  UU UU4S jU5      5      n
SSS5        [        R                  R                  W
5      nU$ ! , (       d  f       N/= f)a  Features for a single channel nd image.

Parameters
----------
img : ndarray
    Input image, which can be grayscale or multichannel.
intensity : bool, default True
    If True, pixel intensities averaged over the different scales
    are added to the feature set.
edges : bool, default True
    If True, intensities of local gradients averaged over the different
    scales are added to the feature set.
texture : bool, default True
    If True, eigenvalues of the Hessian matrix after Gaussian blurring
    at different scales are added to the feature set.
sigma_min : float, optional
    Smallest value of the Gaussian kernel used to average local
    neighborhoods before extracting features.
sigma_max : float, optional
    Largest value of the Gaussian kernel used to average local
    neighborhoods before extracting features.
num_sigma : int, optional
    Number of values of the Gaussian kernel between sigma_min and sigma_max.
    If None, sigma_min multiplied by powers of 2 are used.
num_workers : int or None, optional
    The number of parallel threads to use. If set to ``None``, the full
    set of available cores are used.

Returns
-------
features : list
    List of features, each element of the list is an array of shape as img.
N   r   T)numbaseendpoint)max_workersc                    > [        TU TTTS9$ )N)r=   r>   r?   )rA   )sr>   r<   r=   r?   s    r   <lambda>9_mutiscale_basic_features_singlechannel.<locals>.<lambda>i   s    Ciugr   )r.   ascontiguousarrayr   intlog2logspacer   listr    	itertoolschainfrom_iterable)r<   r=   r>   r?   	sigma_min	sigma_max	num_sigmanum_workerssigmasex
out_sigmasfeaturess   ````        r   '_mutiscale_basic_features_singlechannelr\   0   s    X 

~c2
3C	*RWWY-??!CD	[[
	
	F 
+	."FF 	

 
/ ,,Z8HO 
/	.s   )#C55
D)channel_axisc                  ^ ^^^^^^^ [        TTT/5      (       d  [        S5      eUc  T S[        R                  4   m SnOUS:w  a  [        R                  " T US5      m UU UUUUUU4S j[        T R                  S   5       5       n	[        [        R                  R                  U	5      5      n
[        R                  " U
SS9nU$ )a  Local features for a single- or multi-channel nd image.

Intensity, gradient intensity and local structure are computed at
different scales thanks to Gaussian blurring.

Parameters
----------
image : ndarray
    Input image, which can be grayscale or multichannel.
intensity : bool, default True
    If True, pixel intensities averaged over the different scales
    are added to the feature set.
edges : bool, default True
    If True, intensities of local gradients averaged over the different
    scales are added to the feature set.
texture : bool, default True
    If True, eigenvalues of the Hessian matrix after Gaussian blurring
    at different scales are added to the feature set.
sigma_min : float, optional
    Smallest value of the Gaussian kernel used to average local
    neighborhoods before extracting features.
sigma_max : float, optional
    Largest value of the Gaussian kernel used to average local
    neighborhoods before extracting features.
num_sigma : int, optional
    Number of values of the Gaussian kernel between sigma_min and sigma_max.
    If None, sigma_min multiplied by powers of 2 are used.
num_workers : int or None, optional
    The number of parallel threads to use. If set to ``None``, the full
    set of available cores are used.
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
-------
features : np.ndarray
    Array of shape ``image.shape + (n_features,)``. When `channel_axis` is
    not None, all channels are concatenated along the features dimension.
    (i.e. ``n_features == n_features_singlechannel * n_channels``)
z[At least one of `intensity`, `edges` or `textures`must be True for features to be computed..c              3   N   >#    U  H  n[        TS U4   TTT	TTTTS9v   M     g7f).)r=   r>   r?   rT   rU   rV   rW   N)r\   )
.0dimr>   imager=   rV   rW   rU   rT   r?   s
     r   	<genexpr>,multiscale_basic_features.<locals>.<genexpr>   sA       *C 	0#s(O#		
 *s   "%r*   )any
ValueErrorr.   newaxismoveaxisr,   shaperP   rQ   rR   rS   stack)rc   r=   r>   r?   rT   rU   rV   rW   r]   all_resultsr[   outs   ````````    r   multiscale_basic_featuresrn   s   s    r 	5'*++8
 	
 c2::o&		E<4  R)K IOO11+>?H
((8"
%CJr   )TTT)TTTg      ?   NN)rQ   r   numpyr.   skimager   r   skimage.util.dtyper   _shared._dependency_checksr   concurrent.futuresr	   r   
contextlibr
   r6   rA   r\   rn   r   r   r   <module>rv      s    3   $ - 0E1&- & 59  
@J 
S Sr   