Dear Math and Physics fans(adsbygoogle = window.adsbygoogle || []).push({});

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

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

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:

Loading...

Similar Threads for Matlab Replace pixels |
---|

MATLAB MATLAB: forces acting on an object |

MATLAB Matlab histogram |

MATLAB Sovling Bernoulli's differential equation in matlab? |

MATLAB Matlab-like software |

MATLAB Matlab data into bins |

**Physics Forums | Science Articles, Homework Help, Discussion**