U
    ?h                     @   s.   d dl mZ d dlZdgZdddddZdS )    Ncontingency_tableF)ignore_labels	normalizec                C   sb   |dkrg }| d}|  d}tj||ddt}|rH|t| }t|||ff }|S )a  
    Return the contingency table for all regions in matched segmentations.

    Parameters
    ----------
    im_true : ndarray of int
        Ground-truth label image, same shape as im_test.
    im_test : ndarray of int
        Test image.
    ignore_labels : sequence of int, optional
        Labels to ignore. Any part of the true image labeled with any of these
        values will not be counted in the score.
    normalize : bool
        Determines if the contingency table is normalized by pixel count.

    Returns
    -------
    cont : scipy.sparse.csr_matrix
        A contingency table. `cont[i, j]` will equal the number of voxels
        labeled `i` in `im_true` and `j` in `im_test`.
    NT)invert)	ZreshapenpisinZastypefloatZcount_nonzerosparseZ
coo_matrixZtocsr)Zim_trueZim_testr   r   Z	im_test_rZ	im_true_rdatacont r   T/var/www/html/venv/lib/python3.8/site-packages/skimage/metrics/_contingency_table.pyr      s    

)Zscipy.sparser
   numpyr   __all__r   r   r   r   r   <module>   s
   