The code of matlab to calculate the moment of tchebitchf and reconstruct image is correct ???????

2 vues (au cours des 30 derniers jours)
function [tn] = tn( N )
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
tn=ones(N,N);
tntest=zeros(N,N);
for x=1:1:N
tn(x,2)=(2*x+1-N)/N;
%tn(x,2)=(2*x+1-N)*sqrt(3/(N*((N^2)-1)))
for n=3:1:N
tn(x,n)=((((2*n)-1)*tn(x,2)*tn(x,n-1))-((n-1)*(1-((n-1)^2)/(N^2)))*tn(x,n-2))/n;
end
end
%for x=1:1:20
% for n=1:1:6
% tntest(x,n)=tn(x,n)
% end
%end
%plot(tn);
%title('Les graphes du polynome Tchebichef pour N=20');
%xlabel('X');
%ylabel('tn(x)');
%legend('n=0','n=1','n=2','n=3','n=4','n=5');
%plot(tn);
end
***************************************************************************
function [ Tpq ] = moment( f )
%MOMENT Summary of this function goes here
% Detailed explanation goes here
%rgb2gray(f);
N=size(f,1);
Tpq=zeros(5,1);
%t=tn(N);
t=computePolyMatrix(N);
for p=1:1:5
for q=1:1:1
somme=0;
for x=1:1:N
for y=1:1:N
somme=somme+(t(x,p)*t(y,q)*(f(x,y)/255));
end
end
%Tpq(p,q)=somme;
Tpq(p,q)=somme;
end
end
disp(Tpq);
end
*************************************************************************
function [ f ] = reconstruction(Tpq,tn,N)
%RECONSTRUCTION Summary of this function goes here
% Detailed explanation goes here
for x=1:1:N
for y=1:1:N
somme=0;
for m=1:1:5
for n=1:1:1
somme=somme+(Tpq(m,n)*tn(x,m)*tn(y,n));
end
end
f(x,y)=somme;
%double(f);
%disp(f)
end
end
end
*********************************************************************************************
function [ rou ] = rou( n,N )
%ROU Summary of this function goes here
% Detailed explanation goes here
%t=tn(N);
p=N;
%somme=0;
%for x=1:1:N
% somme=somme+((t(x,p))^2);
%end
%rou=somme;
%plot(t)
%plot(rou);
for i=1:1:n
p=p*(1-((i^2)/(N^2)));
%disp(p)
end
rou=p/(2*i+1);
end
*********************************************************************************
function [ ] = main( f )
%MAIN Summary of this function goes here
% Detailed explanation goes here
N=size(f,1);
Tpq=moment(f);
t=tn(N);
image=reconstruction(Tpq,t,N);
%plot (Tpq)
%image2=im2bw(image)
%disp(image2);
imshow(uint8(image));
disp(Tpq)
disp((image))
end
  13 commentaires
Image Analyst
Image Analyst le 29 Jan 2016
What image are you passing in for "f"?
Don't do this:
image=reconstruction(Tpq,t,N);
because image is a built-in function and should not be used as a variable name.
Indexes are (row, column) which is (y, x), not (x,y). The only reason it's not throwing an error is because your image is either square or wider than it is tall.

Connectez-vous pour commenter.

Réponses (2)

Diego Santiago
Diego Santiago le 22 Mai 2018
Hey, did you solve it? I'm doing something with Tchebichef moments but I haven't been able to solve it.

jianqing luo
jianqing luo le 16 Déc 2020
Hey, did you solve it? I found the function 'computePolyMatrix' corresponding to the input parameter of type'double' is not defined。I haven't been able to solve it.and you?

Catégories

En savoir plus sur Images dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by