Journal‎ > ‎

EigenMoments

posted 8 Feb 2012 10:39 by Behzad Tabibian   [ updated 5 Apr 2012 16:23 ]
This page contains a Matlab code which produces EigenMoments for an image or a signal. Description of this algorithm can be found in wikipedia once page becomes available. - UPDATE: It is now available at  http://en.wikipedia.org/wiki/EigenMoments.

% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
% You should have received a copy of the GNU General Public License
% along with this program.  If not, see <http://www.gnu.org/licenses/>.
%author: Behzad Tabibian
%University of Edinburgh

function [W,A,B] = EM(m,c,k)
[A,B]=construct_AB(m,c);
[W]= EM_construct(A,B,k);

function [W]=EM_construct(A,B,k)
%Since B is positive difinite svd decomposition produces the same vecotrs
%as eig function.
[~,D_B,V_B]=svd(B);
m=size(B,1);
%Selecting k bottom  eigenvalues and eigenvectors.
V_B_selected=V_B(:,(m-k+1:m));
D_B_selected=D_B(m-k+1:m,m-k+1:m);
%Constructing W1
W1=V_B_selected*D_B_selected^(-1/2);
%Constructing W1'AW1
W1T_A_W1=W1'*A*W1;
%Eigenanalysis on W1'AW1
[V_W1T_A_W1,D_W1T_A_W1]=eig(W1T_A_W1);
%Constructing W2
W2=V_W1T_A_W1;
W=W1*W2;
function [A,B]=construct_AB(m,c)
%This function produces X'CX, correlation in the signal, and X'NX,
%correlation in noise for GM.
A=zeros(m,m);
for i=0:m-1
    for j=0:m-1
        syms x1 x2
        f=x1^i*x2^j*exp(-1*c*(x1-x2)^2);
        g=inline(vectorize(f),'x1','x2');
        A(i+1,j+1)= dblquad(g,-1,1,-1,1);
    end
end
B=zeros(m,m);
for i=0:m-1
    for j=0:m-1
        B(i+1,j+1)= 1/(i+j+1)*(1^(i+j+1)-(-1)^(i+j+1));
    end
end




Č
ċ
EM.m
(2k)
Behzad Tabibian,
8 Feb 2012 10:40
Comments