How to revolve 1D vector into a 2D matrix with sub-pixel interpolation?

12 views (last 30 days)
Hi,
I would like take a 1D vector and revlove it about an endpoint to create a 2D image with the values of the original vector interpolated over the rotation.
This seems like a surface of revolution problem.
I tried to do this using the 2D filter tool ftrans2() as below:
N = 111;
a = zeros(N,1);
center = round(N/2);
offset = 30;
a([center-offset,center+offset]) = .25;
a([center-offset+1,center+offset-1]) = .75;
plot(a)
h = ftrans2(a');
imagesc(h)
Thanks for the help
Matt

Accepted Answer

Matt Southwick
Matt Southwick on 30 Jul 2020
Found a solution from Pau GALLES in another thread
[rx,ry]=meshgrid( -order/2:order/2 , -order/2:order/2 );
r = hypot( rx , ry );
halfb = b((length(b)-1)/2 + 1 : end );
vq = interp1( 0:(length(halfb)-1) , halfb , r(:) , 'linear' , 0 );
W=r; W(:)=vq;
Thank you Pau.
Also works for 1D curve to 3D as follows
[rx,ry,rz]=meshgrid( -order/2:order/2 , -order/2:order/2,-order/2:order/2 );
r = sqrt(rx.^2+ry.^2+rz.^2);
halfb = b((length(b)-1)/2 + 1 : end );
vq = interp1( 0:(length(halfb)-1) , halfb , r(:) , 'linear' , 0 );
W=r; W(:)=vq;

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!