Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
to interpolate polar data to cartesian, griddata() or interp2?

Subject: to interpolate polar data to cartesian, griddata() or interp2?

From: Dehuan Xin

Date: 6 Oct, 2013 13:51:09

Message: 1 of 1

Hi, guys
I have a set of data in polar coordinates : [0:179] rows for [0:179] degrees, [1:2049] columns for [-1024:1024] samples along the diameter.
I want to interpolate into cartesian coordinates.

There are two ways to do this:
1) interp2()
convert cartesian coordinates to polar, and interpolate in polar coordinates using interp2.
2) griddata()
compute polar coordinate to cartesian, and then use griddata() to convert scattered data to grid data (which interpolates in cartesian coordinates).

I'm trying to compute CT image reconstruction with Fourier Method.
FFT the sinogram, rearrange it into Fourier domain, and IFFT it to get the image.
I use interp2() which just doesn't work and I don't know where it goes wrong.
Another guy said he tried interp2() and failed, too, but succeeded with griddata().
Then it confuses me whether there's something wrong with my code, or interp2 just does not work for this kind of application?

Here's my code:

clear all
p=phantom(512);
q=radon(p,[0:179])';
q_fft=fftshift(fft(q,[2049],2),2);
q_fft=[q_fft;q_fft(1,end:-1:1)];

 [x,y]=meshgrid([-720:1:720],[720:-1:-720]);
[thg,rg] = cart2pol(x,y);
q_fft2=abs(q_fft);
thg2=unwrap((-0.5*sign(thg+realmin)+0.5)*pi+thg)/pi*180;
rg2=rg.*sign(thg+realmin);

[rn,thn]=meshgrid([-1024:1:1024],[0:1:180]);
q_fft_int= interp2(rn,thn,q_fft,rg2,thg2,'spline');

q_recon=abs(ifft2(ifftshift(q_fft_int)));
 imshow(q_recon,[])


Thanks guys.
Have a nice weekend.

PS: I know Fourier method for CT reconstruction might not be a smart idea, this is just a homework assignment.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us