
    k hk                     4    d Z ddgZddlZddlmZmZ d Zd Zy)z2
:author: Gary Ruben, 2009
:license: modified BSD
frt2ifrt2    N)rollnewaxisc                    | j                   dk7  s| j                  d   | j                  d   k7  rt        d      | j                         }|j                  d   }t	        j
                  |dz   |ft        j                        }|j                  d      |d<   t        d|      D ];  }t        d|      D ]  }t        ||   |       ||<    |j                  d      ||<   = |j                  d      ||<   |S )a  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         /home/developers/rajanand/mypropertyqr-fmb-refixing-v2/venv/lib/python3.12/site-packages/skimage/transform/finite_radon_transform.pyr   r      s    T 	vv{aggajAGGAJ.<==	
B
A
!a%RYY'A66q6>AaD1a[ A; 	*C2c7SD)BsG	*vv1v~!	
 66q6>AaDH    c                 H   | j                   dk7  s"| j                  d   | j                  d   dz   k7  rt        d      | j                         dd }|j                  d   }t	        j
                  ||ft        j                        }|j                  d      |d<   t        d|      D ]G  }t        d|j                  d         D ]  }t        ||   |      ||<    |j                  d      ||<   I || d   t           j                  z  }||d   j                         z
  |z  }|S )aF  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
!Q#A66q6>AaD1a[ BHHQK( 	)C2c7C(BsG	)vv1v~!	
 2w		A	
RUYY[AAHr   )__doc____all__numpyr   r   r   r   r    r   r   <module>r%      s'   
 7
  7t>r   