Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

[Matlab] Replace pixels of an image with theta of Polar Coordinates

Tags:
  1. Apr 15, 2014 #1
    Dear Math and Physics fans

    You have always been so helpful in the past and I was hoping that I could call on your expertise once again.

    I want to make a wedge filter in matlab so I can determine the orientation of the ellipse of a centered 2D fft.

    I tried to make an new image where each pixel coordinate corresponded to the angle from the center. I was then going to use a simple for loop to sum of the 2d fft values that were within the bounds of certain angles.

    When I tried to make the image which contained the polar coordinates as pixel intensities I got some very odd results back. For instance, the image as a whole seems to be skewed by 45 degrees. If any of you guys have any experience with this could you have a look at my code and tell me where I might be going wrong?

    %% do fft

    S=fftshift(fft2(fftshift(double(img))));
    S = 20*log10(abs(S));
    S=medfilt2(S,[5 5]);

    %% make image where pixel vals are angles in degrees

    sx=size(S);
    [x,y]=meshgrid(1:round(sx(2)/2),1:round(sx(1)/2));
    [x2,y2]=meshgrid(1:round(sx(2)/2),1:round(sx(1)/2));
    [x3,y3]=meshgrid(1:round(sx(2)/2),1:round(sx(1)/2));
    [x4,y4]=meshgrid(1:round(sx(2)/2),1:round(sx(1)/2));
    t=atan(x./y);
    t2=atan(x2./y2);
    t3=atan(x3./y3);
    t4=atan(x4./y4);
    t2=flipud(t2);
    t3=fliplr(t3);
    t3=flipud(t3);
    t4=fliplr(t4);
    t5=[t3,t2;t4,t];

    tmp1=sin(2.*t5);
    tmp2=cos(2.*t5);

    ty=((tmp1)./(tmp2));
    tr=ty/2;
    tr=atan(tr);
    tr=tr.*(180/pi);
    tr(isnan(tr)==1)=90;


    Any help would be really appreciated. Thanking you in advance

    D
     
  2. jcsd
  3. Apr 15, 2014 #2
    who knew this existed

    [theta,rho] = cart2pol

    sorry to be a pain cheers

    D
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: [Matlab] Replace pixels of an image with theta of Polar Coordinates
Loading...