
    9i                          S SK rSS.S jrS rg)    N)dtypec                   UcS  U R                   R                  R                  S:X  a/  [        R                  " U R                  [        R
                  5      nU n[        U R                  5       H  nUR                  X1S9nM     U$ )aZ  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.

f)axisr   )	realr   kindnppromote_typesfloat64rangendimcumsum)imager   Sis       Z/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/skimage/transform/integral.pyintegral_imager      sh    D }))..#5  bjj9A5::HH!H) H    c                 4   [         R                  " [         R                  " U5      5      n[         R                  " [         R                  " U5      5      nUR                  S   nU R                  n[         R                  " XCS/5      nUS:  nUS:  nX-   U-  X) -  -   nX$-   U-  X&) -  -   n[         R
                  " X!-
  S:  5      (       a  [        S5      e[         R                  " U5      nSU R                  -  n[        [        US-
  5      SS 5      n	[        U5       H  n
[        U
5      SS R                  U	5      nU Vs/ s H  oS:H  PM	     nnS[        U5      -  n[        U5       Vs/ s H$  n[         R
                  " X   S-
  U-  S:  5      PM&     nnU[         R                  " U5      -  US-
  U-  -   nU[        U5       Vs/ s H,  nUU   (       d  U[        U [!        UU   5         5      -  OSPM.     sn-  nM     U$ s  snf s  snf s  snf )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   N1)r	   
atleast_2darrayshapetileany
IndexErrorzerosr   lenbinr   zfillsuminvertfloattuple)iistartendrowstotal_shapestart_negativesend_negativesr   bit_permwidthr   binarybit	bool_masksignrbadcorner_pointss                     r   	integrater8   0   s   J MM"((5/*E
--
&C;;q>D((K''+ay1K aiO!GM O3e>P6PPE
-6F0F
FC	vvs{a  LMM 	A"''zHHqL!!"%&E 8_Q!!%(+126CCZ6	2s9~% ?DDk
>IBFFUX\Y.!34k 	 
 		) 45QY)#
 	
4[
  ?B!fD5E-"234551L 
 	
 & H! 3

s   H0+H3H)numpyr	   r   r8    r   r   <module>r;      s     $( )Xar   