
    0-Ph}                     R    d dl Zd dlmZ ddlmZmZ 	 	 	 	 dej        dd	Z	dd
Z
dS )    N)ndimage   )_validate_interpolation_order_fix_ndimage_mode   reflect        )reduce_funcc                   
 t           j                  t                    t          |||          
 j        dk    rR 
fdt           j        d                   D             }t          j        t          j	        |          d          }nt          j         
dk              }t          j        |d          }||}	n6	  ||d          }	n'# t          $ r t          j        ||d
          }	Y nw xY w|	S )a#  Return the intensity profile of an image measured along a scan line.

    Parameters
    ----------
    image : ndarray, shape (M, N[, C])
        The image, either grayscale (2D array) or multichannel
        (3D array, where the final axis contains the channel
        information).
    src : array_like, shape (2,)
        The coordinates of the start point of the scan line.
    dst : array_like, shape (2,)
        The coordinates of the end point of the scan
        line. The destination point is *included* in the profile, in
        contrast to standard numpy indexing.
    linewidth : int, optional
        Width of the scan, perpendicular to the line
    order : int in {0, 1, 2, 3, 4, 5}, optional
        The order of the spline interpolation, default is 0 if
        image.dtype is bool and 1 otherwise. The order has to be in
        the range 0-5. See `skimage.transform.warp` for detail.
    mode : {'constant', 'nearest', 'reflect', 'mirror', 'wrap'}, optional
        How to compute any values falling outside of the image.
    cval : float, optional
        If `mode` is 'constant', what constant value to use outside the image.
    reduce_func : callable, optional
        Function used to calculate the aggregation of pixel values
        perpendicular to the profile_line direction when `linewidth` > 1.
        If set to None the unreduced array will be returned.

    Returns
    -------
    return_value : array
        The intensity profile along the scan line. The length of the profile
        is the ceil of the computed length of the scan line.

    Examples
    --------
    >>> x = np.array([[1, 1, 1, 2, 2, 2]])
    >>> img = np.vstack([np.zeros_like(x), x, x, x, np.zeros_like(x)])
    >>> img
    array([[0, 0, 0, 0, 0, 0],
           [1, 1, 1, 2, 2, 2],
           [1, 1, 1, 2, 2, 2],
           [1, 1, 1, 2, 2, 2],
           [0, 0, 0, 0, 0, 0]])
    >>> profile_line(img, (2, 1), (2, 4))
    array([1., 1., 2., 2.])
    >>> profile_line(img, (1, 0), (1, 6), cval=4)
    array([1., 1., 1., 2., 2., 2., 2.])

    The destination point is included in the profile, in contrast to
    standard numpy indexing.
    For example:

    >>> profile_line(img, (1, 0), (1, 6))  # The final point is out of bounds
    array([1., 1., 1., 2., 2., 2., 2.])
    >>> profile_line(img, (1, 0), (1, 5))  # This accesses the full first row
    array([1., 1., 1., 2., 2., 2.])

    For different reduce_func inputs:

    >>> profile_line(img, (1, 0), (1, 3), linewidth=3, reduce_func=np.mean)
    array([0.66666667, 0.66666667, 0.66666667, 1.33333333])
    >>> profile_line(img, (1, 0), (1, 3), linewidth=3, reduce_func=np.max)
    array([1, 1, 1, 2])
    >>> profile_line(img, (1, 0), (1, 3), linewidth=3, reduce_func=np.sum)
    array([2, 2, 2, 4])

    The unreduced array will be returned when `reduce_func` is None or when
    `reduce_func` acts on each pixel value individually.

    >>> profile_line(img, (1, 2), (4, 2), linewidth=3, order=0,
    ...     reduce_func=None)
    array([[1, 1, 2],
           [1, 1, 2],
           [1, 1, 2],
           [0, 0, 0]])
    >>> profile_line(img, (1, 0), (1, 3), linewidth=3, reduce_func=np.sqrt)
    array([[1.        , 1.        , 0.        ],
           [1.        , 1.        , 0.        ],
           [1.        , 1.        , 0.        ],
           [1.41421356, 1.41421356, 0.        ]])
    )	linewidth   c           
      \    g | ](}t          j        d |f         dk              )S ).r   	prefilterordermodecval)ndimap_coordinates).0ir   imager   r   
perp_liness     W/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/skimage/measure/profile.py
<listcomp>z profile_line.<locals>.<listcomp>k   s[     

 

 

  c1f!)  

 

 

    r   )r   r   r   r   r   )axisN)arrr   )r   dtyper   _line_profile_coordinatesndimrangeshapenp	transposeasarrayr   r   flip	TypeErrorapply_along_axis)r   srcdstr   r   r   r   r
   pixelsintensitiesr   s   `   ```   @r   profile_liner.      s\   ~ *%+u==ET""D*3yIIIJzQ

 

 

 

 

 

 

 

 5;q>**

 

 

 bj00)<<$:%dQU
 
 

 WV!$$$F	O%+f1555KK 	O 	O 	O-kvANNNKKK	O s   C! !!DDc                    t          j        | t                    x\  }}} t          j        |t                    x\  }}}|| z
  \  }}t          j        ||          }	t	          t          j        t          j        ||          dz                       }
t          j        |||
          }t          j        |||
          }dz
  t          j        |	           z  dz  dz
  t          j	        |	          z  dz  t          j
        fd|D                       }t          j
        fd|D                       }t          j
        ||g          S )a  Return the coordinates of the profile of an image along a scan line.

    Parameters
    ----------
    src : 2-tuple of numeric scalar (float or int)
        The start point of the scan line.
    dst : 2-tuple of numeric scalar (float or int)
        The end point of the scan line.
    linewidth : int, optional
        Width of the scan, perpendicular to the line

    Returns
    -------
    coords : array, shape (2, N, C), float
        The coordinates of the profile along the scan line. The length of the
        profile is the ceil of the computed length of the scan line.

    Notes
    -----
    This is a utility method meant to be used internally by skimage functions.
    The destination point is included in the profile, in contrast to
    standard numpy indexing.
    )r   r   r   c                 H    g | ]}t          j        |z
  |z             S  r$   linspace)r   row_ir   	row_widths     r   r   z-_line_profile_coordinates.<locals>.<listcomp>   A     	
 	
 	
 K	)59+<iHH	
 	
 	
r   c                 H    g | ]}t          j        |z
  |z             S r1   r2   )r   col_i	col_widthr   s     r   r   z-_line_profile_coordinates.<locals>.<listcomp>   r6   r   )r$   r&   floatarctan2intceilhypotr3   sincosstack)r*   r+   r   src_rowsrc_coldst_rowdst_cold_rowd_colthetalengthline_colline_row	perp_rows	perp_colsr9   r5   s     `            @@r   r    r       s|   0  Z59999GWsZ59999GWs9LE5Jue$$E%//!34455F {7GV44H{7GV44H
 Q"&%..014IQ"&--/!3I	
 	
 	
 	
 	
!	
 	
 	
 I 	
 	
 	
 	
 	
!	
 	
 	
 I 8Y	*+++r   )r   Nr   r	   )r   )numpyr$   scipyr   r   _shared.utilsr   r   meanr.   r    r1   r   r   <module>rR      s                    L L L L L L L L 
		@ @ @ @ @ @F4, 4, 4, 4, 4, 4,r   