Skip to content

Commit

Permalink
New
Browse files Browse the repository at this point in the history
  • Loading branch information
ShurenQi committed Feb 23, 2024
1 parent 3b05c77 commit 6f6fb5f
Show file tree
Hide file tree
Showing 254 changed files with 10,484 additions and 0 deletions.
50 changes: 50 additions & 0 deletions 1. Hierarchical Invariants/Functions/DIR.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
function [featcell,time] = DIR(img,param)
%% input
if size(img,3) ~= 1
img = rgb2gray(img);
end
img = double(img);
fprintf('START DIR\n'); drawnow();
timestamp = tic;
%% get basis function data
bfdatacell = cell(1,param.numofscale);
for ns = 1:1:param.numofscale
sizeofbf = param.scales(ns);
if mod(sizeofbf,2) == 1
sizeofbf = sizeofbf - 1;
end
if param.type_feat == 1 || param.type_feat == 2
bfdatacell{ns} = getBF(param.type_feat,sizeofbf,param.ZNM,param.alpha, param.p, param.q);
elseif param.type_feat == 11 || param.type_feat == 17
bfdatacell{ns} = getBF(param.type_feat,sizeofbf,param.SNM,param.alpha, param.p, param.q);
else
bfdatacell{ns} = getBF(param.type_feat,sizeofbf,param.NM,param.alpha, param.p, param.q);
end
end
%% naive feature generation
% raggioU = ceil((sizeofbf-1)/2);
% raggioL = floor((sizeofbf-1)/2);
% featcell = cell(1,param.numofscale);
% for ns = 1:1:param.numofscale
% featcell{ns} = abs(bf_filter(img, bfdatacell{ns}));
% featcell{ns} = featcell{ns}((1+raggioU):(end-raggioL),(1+raggioU):(end-raggioL),:);
% end
%% fast feature generation by FFT (Convolution Theorem)
featcell = cell(1,param.numofscale);
fft_img = fft2(img);
nof = size(bfdatacell{1},3);
fft_img_cell = single(zeros([size(img), nof]));
for i = 1:1:nof
fft_img_cell(:,:,i) = fft_img;
end
featcell{param.numofscale} = abs(bf_filter_fft(img, fft_img_cell, bfdatacell{param.numofscale}));
unisize = size (featcell{param.numofscale});
for ns = 1:1:param.numofscale-1
temp = abs(bf_filter_fft(img, fft_img_cell, bfdatacell{ns}));
rr = (size(temp)-unisize)/2;
featcell{ns} = temp ((1+rr(1)):(end-rr(1)),(1+rr(2)):(end-rr(2)),:);
end
%% output
clc;
time = toc(timestamp);
end
32 changes: 32 additions & 0 deletions 1. Hierarchical Invariants/Functions/HI.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
function [ord,featcell] = HI(img,param)
K = max(max(param.XNM));
idx = 1;
featcell = cell(1,1);
ord = zeros(1,1);
for x = 0:K
if x == 0
param.NM = param.XNM(1,:);
[feat,~] = DIR(img,param);
featcell(1)=feat;
ord(1)=x;
else
param.NM = param.XNM(idx:idx+x,:);
inputfeat=img;
[feat,~] = DIR(inputfeat,param);
for z=1:size(feat{1},3)
featcell = [featcell, {feat{1}(:,:,z)}];
ord =[ord, x];
end
for y = idx-x:idx-1
param.NM = param.XNM(idx:idx+x,:);
inputfeat=featcell{y};
[feat,~] = DIR(inputfeat,param);
for z=1:size(feat{1},3)
featcell = [featcell, {feat{1}(:,:,z)}];
ord =[ord, x];
end
end
end
idx=idx+x+1;
end
end
161 changes: 161 additions & 0 deletions 1. Hierarchical Invariants/Functions/MOMENT/getBF.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
function [BF]=getBF(MODE,SZ,NM,alpha,p,q)
[rho,theta]=ro(SZ,SZ);
pz=rho>1; cnt=sum(pz(:));rho(pz)= 0.5;
L=size(NM,1);
BF=zeros(SZ,SZ,L);
%% ZM
if MODE==1
for index =1:1:L
order = NM(index,1); repetition = NM(index,2);
R=getZM_RBF(order,repetition,rho);
pupil =R.*exp(-1j*repetition * theta);
pupil(pz) = 0;
BF(:,:,index)=(1/cnt).*pupil;
end
%% PZM
elseif MODE==2
for index =1:1:L
order = NM(index,1); repetition = NM(index,2);
R=getPZM_RBF(order,repetition,rho);
pupil =R.*exp(-1j*repetition * theta);
pupil(pz) = 0;
BF(:,:,index)=(1/cnt).*pupil;
end
%% OFMM
elseif MODE==3
for index =1:1:L
order = NM(index,1); repetition = NM(index,2);
R=getOFMM_RBF(order,rho);
pupil =R.*exp(-1j*repetition * theta);
pupil(pz) = 0;
BF(:,:,index)=(1/cnt).*pupil;
end
%% CHFM
elseif MODE==4
for index =1:1:L
order = NM(index,1); repetition = NM(index,2);
R=getCHFM_RBF(order,rho);
pupil =R.*exp(-1j*repetition * theta);
pupil(pz) = 0;
BF(:,:,index)=(1/cnt).*pupil;
end
%% PJFM
elseif MODE==5
for index =1:1:L
order = NM(index,1); repetition = NM(index,2);
R=getPJFM_RBF(order,rho);
pupil =R.*exp(-1j*repetition * theta);
pupil(pz) = 0;
BF(:,:,index)=(1/cnt).*pupil;
end
%% JFM
elseif MODE==6
for index =1:1:L
order = NM(index,1); repetition = NM(index,2);
R=getJFM_RBF(order,rho,p,q);
pupil =R.*exp(-1j*repetition * theta);
pupil(pz) = 0;
BF(:,:,index)=(1/cnt).*pupil;
end
%% RHFM
elseif MODE==7
for index =1:1:L
order = NM(index,1); repetition = NM(index,2);
R=getRHFM_RBF(order,rho);
pupil =R.*exp(-1j*repetition * theta);
pupil(pz) = 0;
BF(:,:,index)=(1/cnt).*pupil;
end
%% EFM
elseif MODE==8
for index =1:1:L
order = NM(index,1); repetition = NM(index,2);
R=getEFM_RBF(order,rho);
pupil =R.*exp(-1j*repetition * theta);
pupil(pz) = 0;
BF(:,:,index)=(1/cnt).*pupil;
end
%% PCET
elseif MODE==9
for index =1:1:L
order = NM(index,1); repetition = NM(index,2);
R=getPCET_RBF(order,rho);
pupil =R.*exp(-1j*repetition * theta);
pupil(pz) = 0;
BF(:,:,index)=(1/cnt).*pupil;
end
%% PCT
elseif MODE==10
for index =1:1:L
order = NM(index,1); repetition = NM(index,2);
R=getPCT_RBF(order,rho);
pupil =R.*exp(-1j*repetition * theta);
pupil(pz) = 0;
BF(:,:,index)=(1/cnt).*pupil;
end
%% PST
elseif MODE==11
for index =1:1:L
order = NM(index,1); repetition = NM(index,2);
R=getPST_RBF(order,rho);
pupil =R.*exp(-1j*repetition * theta);
pupil(pz) = 0;
BF(:,:,index)=(1/cnt).*pupil;
end
%% BFM
elseif MODE==12
v=1;
for index =1:1:L
order = NM(index,1); repetition = NM(index,2);
R=getBFM_RBF(order,rho,v);
pupil =R.*exp(-1j*repetition * theta);
pupil(pz) = 0;
BF(:,:,index)=(1/cnt).*pupil;
end
%% FJFM
elseif MODE==13
for index =1:1:L
order = NM(index,1); repetition = NM(index,2);
R=getFJFM_RBF(order,rho,p,q,alpha);
pupil =R.*exp(-1j*repetition * theta);
pupil(pz) = 0;
BF(:,:,index)=(1/cnt).*pupil;
end
%% GRHFM
elseif MODE==14
for index =1:1:L
order = NM(index,1); repetition = NM(index,2);
R=getGRHFM_RBF(order,rho,alpha);
pupil =R.*exp(-1j*repetition * theta);
pupil(pz) = 0;
BF(:,:,index)=(1/cnt).*pupil;
end
%% GPCET
elseif MODE==15
for index =1:1:L
order = NM(index,1); repetition = NM(index,2);
R=getGPCET_RBF(order,rho,alpha);
pupil =R.*exp(-1j*repetition * theta);
pupil(pz) = 0;
BF(:,:,index)=(1/cnt).*pupil;
end
%% GPCT
elseif MODE==16
for index =1:1:L
order = NM(index,1); repetition = NM(index,2);
R=getGPCT_RBF(order,rho,alpha);
pupil =R.*exp(-1j*repetition * theta);
pupil(pz) = 0;
BF(:,:,index)=(1/cnt).*pupil;
end
%% GPST
elseif MODE==17
for index =1:1:L
order = NM(index,1); repetition = NM(index,2);
R=getGPST_RBF(order,rho,alpha);
pupil =R.*exp(-1j*repetition * theta);
pupil(pz) = 0;
BF(:,:,index)=(1/cnt).*pupil;
end
end

17 changes: 17 additions & 0 deletions 1. Hierarchical Invariants/Functions/MOMENT/getBFM_RBF.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
%% REF
% Xiao B, Ma J, Wang X. Image analysis by Bessel¨CFourier moments. Pattern Recognition, 2010, 43(8): 2620-2629.
function [output] = getBFM_RBF(order,rho,v)
Roots=zeros(1,max(order)+2);
syms x;
Roots(1,1)=vpasolve(besselj(v, x) == 0, x);
for i=2:1:max(order)+2
ST=Roots(1,i-1)+3;
Roots(1,i)=vpasolve(besselj(v, x) == 0, ST);
end
% obtain the order and repetition
n = order;
% compute the radial polynomial
rho=rho*Roots(n+2);
output=besselj(v,rho);
output=output*sqrt((1/(pi*(besselj(v+1,Roots(order+2)))^2)));
end % end getRadialPoly method
40 changes: 40 additions & 0 deletions 1. Hierarchical Invariants/Functions/MOMENT/getCHFM_RBF.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
%% REF
%¡¡Ping Z, Wu R, Sheng Y. Image description with Chebyshev¨CFourier moments. Journal of the Optical Society of America A, 2002, 19(9): 1748-1754.
% H. Yang, S. Qi, J. Tian, P. Niu, X. Wang, Robust and discriminative image representation: Fractional-order Jacobi-Fourier moments, Pattern Recognition.
function [output] = getCHFM_RBF(order,rho)
% obtain the order
n = order;
p = 2; q = 1.5; alpha = 1;
% PN
if n>=2
P0=(gamma(p)/gamma(q))*ones(size(rho));
P1=(gamma(p+1)/gamma(q))*(1-((p+1)/q)*(rho.^alpha));
PN1=P1;PN2=P0;
for k = 2:n
L1=-((2*k+p-1)*(2*k+p-2))/(k*(q+k-1));
L2=(p+2*k-2)+(((k-1)*(q+k-2)*L1)/(p+2*k-3));
L3=((p+2*k-4)*(p+2*k-3)/2)+((q+k-3)*(k-2)*L1/2)-((p+2*k-4)*L2);
PN=(L1*(rho.^alpha)+L2).*PN1+L3.*PN2;
PN2=PN1;
PN1=PN;
end
elseif n==1
PN=(gamma(p+1)/gamma(q))*(1-((p+1)/q)*(rho.^alpha));
elseif n==0
PN=(gamma(p)/gamma(q))*ones(size(rho));
end

%AN
if n>=1
A0=sqrt(gamma(q)/(gamma(p)*gamma(p-q+1)));
AN1=A0;
for k = 1:n
AN=sqrt(k*(q+k-1)/((p+k-1)*(p-q+k)))*AN1;
AN1=AN;
end
elseif n==0
AN=sqrt(gamma(q)/(gamma(p)*gamma(p-q+1)));
end

output=sqrt((p+2*n)*alpha*((1-rho.^alpha).^(p-q)).*(rho.^(alpha*q-1))./rho)*AN.*PN;
end % end getRadialPoly method
6 changes: 6 additions & 0 deletions 1. Hierarchical Invariants/Functions/MOMENT/getEFM_RBF.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
%% REF
% Hu H, Zhang Y, Shao C, et al. Orthogonal moments based on exponent functions: Exponent-Fourier moments. Pattern Recognition, 2014, 47(8): 2596-2606.
function [output] = getEFM_RBF(order,rho)
% compute the radial polynomial
output=sqrt(rho.^(-1)).*exp(1j*2*pi*order.*rho);
end
38 changes: 38 additions & 0 deletions 1. Hierarchical Invariants/Functions/MOMENT/getFJFM_RBF.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
%% REF
% H. Yang, S. Qi, J. Tian, P. Niu, X. Wang, Robust and discriminative image representation: Fractional-order Jacobi-Fourier moments, Pattern Recognition.
function [output] = getFJFM_RBF(order,rho,p,q,alpha)
% obtain the order
n = order;
% PN
if n>=2
P0=(gamma(p)/gamma(q))*ones(size(rho));
P1=(gamma(p+1)/gamma(q))*(1-((p+1)/q)*(rho.^alpha));
PN1=P1;PN2=P0;
for k = 2:n
L1=-((2*k+p-1)*(2*k+p-2))/(k*(q+k-1));
L2=(p+2*k-2)+(((k-1)*(q+k-2)*L1)/(p+2*k-3));
L3=((p+2*k-4)*(p+2*k-3)/2)+((q+k-3)*(k-2)*L1/2)-((p+2*k-4)*L2);
PN=(L1*(rho.^alpha)+L2).*PN1+L3.*PN2;
PN2=PN1;
PN1=PN;
end
elseif n==1
PN=(gamma(p+1)/gamma(q))*(1-((p+1)/q)*(rho.^alpha));
elseif n==0
PN=(gamma(p)/gamma(q))*ones(size(rho));
end

%AN
if n>=1
A0=sqrt(gamma(q)/(gamma(p)*gamma(p-q+1)));
AN1=A0;
for k = 1:n
AN=sqrt(k*(q+k-1)/((p+k-1)*(p-q+k)))*AN1;
AN1=AN;
end
elseif n==0
AN=sqrt(gamma(q)/(gamma(p)*gamma(p-q+1)));
end

output=sqrt((p+2*n)*alpha*((1-rho.^alpha).^(p-q)).*(rho.^(alpha*q-1))./rho)*AN.*PN;
end % end getRadialPoly method
6 changes: 6 additions & 0 deletions 1. Hierarchical Invariants/Functions/MOMENT/getGPCET_RBF.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
%% REF
% Hoang T V, Tabbone S. Generic polar harmonic transforms for invariant image representation. Image and Vision Computing, 2014, 32(8): 497-509.
function [output] = getGPCET_RBF(order,rho,alpha)
% compute the radial polynomial
output=sqrt(alpha*rho.^(alpha-2)).*exp(1j*2*pi*order.*(rho.^alpha));
end % end getRadialPoly method
10 changes: 10 additions & 0 deletions 1. Hierarchical Invariants/Functions/MOMENT/getGPCT_RBF.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
%% REF
% Hoang T V, Tabbone S. Generic polar harmonic transforms for invariant image representation. Image and Vision Computing, 2014, 32(8): 497-509.
function [output] = getGPCT_RBF(order,rho,alpha)
% compute the radial polynomial
if order==0
output=sqrt(alpha*rho.^(alpha-2));
else
output=sqrt(alpha*rho.^(alpha-2)).*sqrt(2).*cos(pi*order.*rho.^alpha);
end
end
6 changes: 6 additions & 0 deletions 1. Hierarchical Invariants/Functions/MOMENT/getGPST_RBF.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
%% REF
% Hoang T V, Tabbone S. Generic polar harmonic transforms for invariant image representation. Image and Vision Computing, 2014, 32(8): 497-509.
function [output] = getGPST_RBF(order,rho,alpha)
% compute the radial polynomial
output=sqrt(alpha*rho.^(alpha-2)).*sqrt(2).*sin(pi*order.*rho.^alpha);
end % end getRadialPoly method
12 changes: 12 additions & 0 deletions 1. Hierarchical Invariants/Functions/MOMENT/getGRHFM_RBF.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
%% REF
% Hoang T V, Tabbone S. Generic polar harmonic transforms for invariant image representation. Image and Vision Computing, 2014, 32(8): 497-509.
function [output] = getGRHFM_RBF(order,rho,alpha)
% compute the radial polynomial
if order==0
output=sqrt(alpha*rho.^(alpha-2));
elseif mod(order,2)==1
output=sqrt(alpha*rho.^(alpha-2)).*sqrt(2).*sin(pi*(order+1).*rho.^alpha);
else
output=sqrt(alpha*rho.^(alpha-2)).*sqrt(2).*cos(pi*order.*rho.^alpha);
end
end % end getRadialPoly method
Loading

0 comments on commit 6f6fb5f

Please sign in to comment.