
    0-Ph                         d dl Zd dlmZ ddlmZ ddlmZ 	 d dl m	Z	 n# e
$ r	 d dlm	Z	 Y nw xY wdgZ ej         ej        d                    Zddej        fd	ZdS )
    N   )rgb2gray)img_as_float)	AxisErrorblur_effect      c                    |^	 t          j        | |d          } n7# t          $ r t          d            t          $ r t          d            w xY wt          |           } | j        }t          |           } | j        }g }ddl	m
} t          d |D                       }t          |          D ]}	t          j        | ||	          }
t          j         || |	                    }t          j         ||
|	                    }t          j        t"          |          }t          j        t"          |          }t          j        d	||z
            }t          j        ||                   }t          j        ||                   }|                    t          j        ||z
            |z             ||n
 ||          S )
a  Compute a metric that indicates the strength of blur in an image
    (0 for no blur, 1 for maximal blur).

    Parameters
    ----------
    image : ndarray
        RGB or grayscale nD image. The input image is converted to grayscale
        before computing the blur metric.
    h_size : int, optional
        Size of the re-blurring filter.
    channel_axis : int or None, optional
        If None, the image is assumed to be grayscale (single-channel).
        Otherwise, this parameter indicates which axis of the array
        corresponds to color channels.
    reduce_func : callable, optional
        Function used to calculate the aggregation of blur metrics along all
        axes. If set to None, the entire list is returned, where the i-th
        element is the blur metric along the i-th axis.

    Returns
    -------
    blur : float (0 to 1) or list of floats
        Blur metric: by default, the maximum of blur metrics along all axes.

    Notes
    -----
    `h_size` must keep the same value in order to compare results between
    images. Most of the time, the default size (11) is enough. This means that
    the metric can clearly discriminate blur up to an average 11x11 filter; if
    blur is higher, the metric still gives good results but its values tend
    towards an asymptote.

    References
    ----------
    .. [1] Frederique Crete, Thierry Dolmiere, Patricia Ladret, and Marina
       Nicolas "The blur effect: perception and estimation with a new
       no-reference perceptual blur metric" Proc. SPIE 6492, Human Vision and
       Electronic Imaging XII, 64920I (2007)
       https://hal.archives-ouvertes.fr/hal-00232709
       :DOI:`10.1117/12.702790`
    Nz6channel_axis must be one of the image array dimensionszchannel_axis must be an integerr   )sobelc                 4    g | ]}t          d |dz
            S )r   r   )slice).0ss     \/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/skimage/measure/_blur_effect.py
<listcomp>zblur_effect.<locals>.<listcomp>S   s$    333E!QUOO333    )axisr   )npmoveaxisr   print	TypeErrorr   ndimr   shapefiltersr   tuplerangendiuniform_filter1dabsmaximum_EPSILONsumappend)imageh_sizechannel_axisreduce_funcn_axesr   Br   slicesaxfilt_imim_sharpim_blurTM1M2s                   r   r   r      s   V 	K|R88EE 	 	 	JKKK 	 	 	3444	 ZFEKE
A33U33344FFmm ' '&uf2>>>6%%B///00&wR00011 :h11*Xw//Jq(W,--VHV$%%VAfI	R2%&&&&#11Q7s	    4A)numpyr   scipy.ndimagendimager   colorr   utilr   r   ImportErrornumpy.exceptions__all__spacingfloat64r"   maxr    r   r   <module>r?      s                         
+ + + +********+ / 2:jbjmm$$ !t L8 L8 L8 L8 L8 L8s    --