
    hk                     4    S r SS/rSSKrSSKJrJr  S rS rg)z2
:author: Gary Ruben, 2009
:license: modified BSD
frt2ifrt2    N)rollnewaxisc                    U R                   S:w  d   U R                  S   U R                  S   :w  a  [        S5      eU R                  5       nUR                  S   n[        R
                  " US-   U4[        R                  5      nUR                  SS9US'   [        SU5       H8  n[        SU5       H  n[        X   U* 5      X'   M     UR                  SS9X4'   M:     UR                  SS9X2'   U$ )aP  Compute the 2-dimensional finite Radon transform (FRT) for the input array.

Parameters
----------
a : ndarray of int, shape (M, M)
    Input array.

Returns
-------
FRT : ndarray of int, shape (M+1, M)
    Finite Radon Transform array of coefficients.

See Also
--------
ifrt2 : The two-dimensional inverse FRT.

Notes
-----
The FRT has a unique inverse if and only if M is prime. [FRT]
The idea for this algorithm is due to Vlad Negnevitski.

Examples
--------

Generate a test image:
Use a prime number for the array dimensions

>>> SIZE = 59
>>> img = np.tri(SIZE, dtype=np.int32)

Apply the Finite Radon Transform:

>>> f = frt2(img)

References
----------
.. [FRT] A. Kingston and I. Svalbe, "Projective transforms on periodic
         discrete image arrays," in P. Hawkes (Ed), Advances in Imaging
         and Electron Physics, 139 (2006)

   r      z!Input must be a square, 2-D arrayaxis)
ndimshape
ValueErrorcopynpemptyuint32sumranger   aainfmrows         b/var/www/fran/franai/venv/lib/python3.13/site-packages/skimage/transform/finite_radon_transform.pyr   r      s    T 	vv{aggajAGGAJ.<==	
B
A
!a%RYY'A66q6>AaD1a[A;C27SD)BG vv1v~	 
 66q6>ADH    c                 >   U R                   S:w  d#  U R                  S   U R                  S   S-   :w  a  [        S5      eU R                  5       SS nUR                  S   n[        R
                  " X"4[        R                  5      nUR                  SS9US'   [        SU5       HD  n[        SUR                  S   5       H  n[        X   U5      X'   M     UR                  SS9X4'   MF     X0S   [           R                  -  nX1S   R                  5       -
  U-  nU$ )a  Compute the 2-dimensional inverse finite Radon transform (iFRT) for the input array.

Parameters
----------
a : ndarray of int, shape (M+1, M)
    Input array.

Returns
-------
iFRT : ndarray of int, shape (M, M)
    Inverse Finite Radon Transform coefficients.

See Also
--------
frt2 : The two-dimensional FRT

Notes
-----
The FRT has a unique inverse if and only if M is prime.
See [1]_ for an overview.
The idea for this algorithm is due to Vlad Negnevitski.

Examples
--------

>>> SIZE = 59
>>> img = np.tri(SIZE, dtype=np.int32)

Apply the Finite Radon Transform:

>>> f = frt2(img)

Apply the Inverse Finite Radon Transform to recover the input

>>> fi = ifrt2(f)

Check that it's identical to the original

>>> assert len(np.nonzero(img-fi)[0]) == 0

References
----------
.. [1] A. Kingston and I. Svalbe, "Projective transforms on periodic
         discrete image arrays," in P. Hawkes (Ed), Advances in Imaging
         and Electron Physics, 139 (2006)

r   r   r	   z0Input must be an (n+1) row x n column, 2-D arrayNr
   )r   r   r   r   r   r   r   r   r   r   r   Tr   s         r   r   r   F   s    ` 	vv{aggajAGGAJN2KLL	
#2B
A
!#A66q6>AaD1a[BHHQK(C27C(BG )vv1v~	 
 2w		A	
UYY[AAHr   )__doc____all__numpyr   r   r   r   r    r   r   <module>r%      s'   
 7
  7t>r   