
    1-Ph                          d dl ZdddZd ZdS )    N)dtypec                    |9| j         j        j        dk    r$t          j        | j        t          j                  }| }t          | j                  D ]}|                    ||          }|S )a  Integral image / summed area table.

    The integral image contains the sum of all elements above and to the
    left of it, i.e.:

    .. math::

       S[m, n] = \sum_{i \leq m} \sum_{j \leq n} X[i, j]

    Parameters
    ----------
    image : ndarray
        Input image.

    Returns
    -------
    S : ndarray
        Integral image/summed area table of same shape as input image.

    Notes
    -----
    For better accuracy and to avoid potential overflow, the data type of the
    output may differ from the input's when the default dtype of None is used.
    For inputs with integer dtype, the behavior matches that for
    :func:`numpy.cumsum`. Floating point inputs will be promoted to at least
    double precision. The user can set `dtype` to override this behavior.

    References
    ----------
    .. [1] F.C. Crow, "Summed-area tables for texture mapping,"
           ACM SIGGRAPH Computer Graphics, vol. 18, 1984, pp. 207-212.

    Nf)axisr   )	realr   kindnppromote_typesfloat64rangendimcumsum)imager   Sis       Z/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/skimage/transform/integral.pyintegral_imager      sl    D }).#55 bj99A5: * *HH!5H))H    c                     t          j        t          j                            t          j        t          j        |                    }j        d         } j        }t          j        ||dg          }dk     }|dk     }|z   |z  | z  z   ||z   |z  || z  z   }t          j        |z
  dk               rt          d          t          j        |          }d j        z  }t          t          |dz
            dd                   }	t          |          D ]}
t          |
          dd                             |	          }d |D             dt                    z  fdt          |          D             |t          j                  z  dz
  z  z   | fd	t          |          D             z  }|S )
a  Use an integral image to integrate over a given window.

    Parameters
    ----------
    ii : ndarray
        Integral image.
    start : List of tuples, each tuple of length equal to dimension of `ii`
        Coordinates of top left corner of window(s).
        Each tuple in the list contains the starting row, col, ... index
        i.e `[(row_win1, col_win1, ...), (row_win2, col_win2,...), ...]`.
    end : List of tuples, each tuple of length equal to dimension of `ii`
        Coordinates of bottom right corner of window(s).
        Each tuple in the list containing the end row, col, ... index i.e
        `[(row_win1, col_win1, ...), (row_win2, col_win2, ...), ...]`.

    Returns
    -------
    S : scalar or ndarray
        Integral (sum) over the given window(s).

    See Also
    --------
    integral_image : Create an integral image / summed area table.

    Examples
    --------
    >>> arr = np.ones((5, 6), dtype=float)
    >>> ii = integral_image(arr)
    >>> integrate(ii, (1, 0), (1, 2))  # sum from (1, 0) to (1, 2)
    array([3.])
    >>> integrate(ii, [(3, 3)], [(4, 5)])  # sum from (3, 3) to (4, 5)
    array([6.])
    >>> # sum from (1, 0) to (1, 2) and from (3, 3) to (4, 5)
    >>> integrate(ii, [(1, 0), (3, 3)], [(1, 2), (4, 5)])
    array([3., 6.])
    r      z1end coordinates must be greater or equal to start   Nc                     g | ]}|d k    	S )1 ).0bits     r   
<listcomp>zintegrate.<locals>.<listcomp>   s    222CSCZ222r   c                 X    g | ]&}t          j        |         d z
  z  dk               'S )r   r   )r	   any)r   r	bool_maskstarts     r   r   zintegrate.<locals>.<listcomp>   sB     
 
 
9:BFU1X\Y.!344
 
 
r   c           
      z    g | ]7}|         s+t          t          |                                      z  nd 8S )r   )floattuple)r   r!   badcorner_pointsiisigns     r   r   zintegrate.<locals>.<listcomp>   sW     
 
 
 ?B!fLD5E-"233455551
 
 
r   )r	   
atleast_2darrayshapetiler    
IndexErrorzerosr   lenbinr   zfillsuminvert)r)   r#   endrowstotal_shapestart_negativesend_negativesr   bit_permwidthr   binaryr'   r"   r(   r*   s   ``          @@@@r   	integrater>   0   s   J M"(5//**E
-
&
&C;q>D(K'+ay11K aiO!GM[ O3e>P6PPE
-6F0F
FC	vsU{a   NLMMM 	A"'zHHqL!!!""%&&E 8__ 
 
Q!!%((226222	s9~~%
 
 
 
 
>CDkk
 
 
 	) 4 45QY)#
 	
 
 
 
 
 
 
 
4[[
 
 
 	
 Hr   )numpyr	   r   r>   r   r   r   <module>r@      sN        $( ) ) ) ) )Xa a a a ar   