[Scilab-users] Radon transform

Tan Chin Luh chinluh at tritytech.com
Wed Nov 15 13:48:10 CET 2017


Hi,

If you are using the Scilab 6, you can consider using IPCV "imradon" 
function.

another implementation in scilab code attached in this email, radon.sci. 
This is pretty slow as it is using a for loop if you were to plot from 
0:179 degree.  this function will need nan toolbox.

hope this helps.

rgds,
CL





On 15/11/2017 8:01 PM, Jean-Philippe Grivet wrote:
> Hello,
>
> Does an implementation of the Radon transform exist in Scilab, similar 
> to the Matlab
> "radon" function ? Would anybody be willing to share a homemade version ?
>
> Thank you for your input
> JP Grivet
>
>
> ---
> L'absence de virus dans ce courrier électronique a été vérifiée par le 
> logiciel antivirus Avast.
> https://www.avast.com/antivirus
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
>

-------------- next part --------------
function [RT,Xp] = radon(I,theta)
     [m, n] = size (I);
    //pause
    // center of image
    xc = floor ((m+1)/2);
    yc = floor ((n+1)/2);

    // divide each pixel into 2x2 subpixels

    d = matrix (I,[1 m 1 n]);
    d = d([1 1],:,[1 1],:);
    d = matrix (d,[2*m 2*n])/4;

    b = ceil (sqrt (sum (size (I).^2))/2 + 1);
    xp = [-b:b]';
    sz = size(xp);

    [X,Y] = ndgrid (0.75 - xc + [0:2*m-1]/2,0.75 - yc + [0:2*n-1]/2);

    X = X(:)';
    Y = Y(:)';
    d = d(:)';

    th = theta*%pi/180;

    for l=1:length (theta)
        // project each pixel to vector (-sin(th),cos(th))
        Xp = -sin (th(l)) * X + cos (th(l)) * Y;

        ip = Xp + b + 1;

        k = floor (ip);
        frac = ip-k;

        RT(:,l) = nan_accumarray (k',d .* (1-frac),sz) + nan_accumarray (k'+1,d .* frac,sz);
    end
endfunction


More information about the users mailing list