function [outimg]=rt2xy(inimg,cx,cy,Nr,Nt,Nx,Ny)

[xi yi]=meshgrid(1:Ny,1:Nx);

[th r]=meshgrid(Nt,Nr);
size(th)

rth=xi+i*yi-cx-i*cy;

ro=abs(rth);
tho=angle(rth)+pi;

%[size(th) size(r) size(inimg) size(tho) size(ro)]

outimg=interp2(th,r,inimg,tho,ro); 


outimg(find(isnan(outimg)))=0;

