hey can u help me that how can i make my zernike moment code, invariant to rotation.

4 Comments

n=4;
m=2
p = rgb2gray(imread('C:\Users\hp\Desktop\2.JPG'));
N = size(p,1);
[ZOH AOH PhiOH] = Zernikmoment(p,n,m);
function [Z A Phi] = Zernikmoment(p,n,m)
N = size(p,1);
x = 1:N; y = x;
[X,Y] = meshgrid(x,y);
R = sqrt((2.*X-N-1).^2+(2.*Y-N-1).^2)/N;
Theta = atan2((N-1-2.*Y+2),(2.*X-N+1-2));
R = (R<=1).*R;
Rad = radialpoly(R,n,m); % get the radial polynomial
Product = p(x,y).*Rad.*exp(-1i*m*Theta);
Z = sum(Product(:)); % calculate the moments
cnt = nnz(R)+1; % count the number of pixels inside the unit circle
Z = (n+1)*Z/cnt; % normalize the amplitude of moments
A = abs(Z); % calculate the amplitude of the moment
Phi = angle(Z)*180/pi; % calculate the phase of the mement
function rad = radialpoly(r,n,m)
rad = zeros(size(r)); % Initilization
for s = 0:(n-abs(m))/2
c = (-1)^s*factorial(n-s)/(factorial(s)*factorial((n+abs(m))/2-s)*factorial((n-abs(m))/2-s));
rad = rad + c*r.^(n-2*s);
end
this code work well with 0, 90 and 180 degree but not with 30 or 45 degree.
What should be looked at to determine whether it is doing well or not?
sir..it is doing well but i want to make my program rotation invariant. how should i do ??

Sign in to comment.

Answers (1)

How can i get angle and magnitude as output image instead features?
A = abs(Z); % calculate the amplitude of the moment
Phi = angle(Z)*180/pi; % calculate the phase of the mement
How to get ,
figure,imshow(A) ?
figure,imshow(Phi) ?

Categories

Find more on Mathematics in Help Center and File Exchange

Products

Tags

Asked:

on 10 Apr 2013

Answered:

on 9 Sep 2019

Community Treasure Hunt

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

Start Hunting!