Bonjour,
je cherche à implémenter l'algorithme de calcul des moments de zernike pour une image. parce que je n'aime pas trop les mathématiques j'ai fait une recherche d'un code source de cet algorithme sans se pencher dans la compréhension des formules mathématiques compliqué. mnt je suis concentré à la compréhension d'un code de Michael V.Boland que j'ai trouvé dans ce site: http://murphylab.web.cmu.edu/publica...hesis_all.html et je cherche quelqu'un pour m'aider.
le code que j'ai trouvé est composé de deux fichier:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
 
% mb_zernike.m
 
function [znames, zvalues] = mb_zernike(I,D,R)
I=imread('c:\base_image\img01.png');
% [ZNAMES, ZVALUES] = MB_ZERNIKE(I,D,R) Zernike moments through degree D 
% MB_ZERNIKE(I,D,R),
%     Returns a vector of Zernike moments through degree D for the
%     image I, and the names of those moments in cell array znames. 
%     R is used as the maximum radius for the Zernike polynomials.
%
%     For use as features, it is desirable to take the 
%     magnitude of the Zernike moments (i.e. abs(zvalues))
%
%     Reference: Teague, MR. (1980). Image Analysis vi athe General
%       Theory of Moments.  J. Opt. Soc. Am. 70(8):920-930.
%
% 19 Dec 98 - M.V. Boland
%
 
% $Id: mb_zernike.m,v 1.4 1999/02/17 14:19:57 boland Exp $
 
znames = {} ;
zvalues = [] ;
 
%
% Find all non-zero pixel coordinates and values
%
[Y,X,P] = find(I) ;
 
%
% Normalize the coordinates to the center of mass and normalize
%  pixel distances using the maximum radius argument (R)
%
Xn = (X-mb_imgmoments(I,1,0)/mb_imgmoments(I,0,0))/R ;
Yn = (Y-mb_imgmoments(I,0,1)/mb_imgmoments(I,0,0))/R ;
 
%
% Find all pixels of distance <= 1.0 to center
%
k = find(sqrt(Xn.^2 + Yn.^2) <= 1.0) ;
 
 
for n=0:D,
  for l=0:n,
    if (mod(n-l,2)==0)
	znames = [znames cellstr(sprintf('Z_%i,%i', n, l))] ;
	zvalues = [zvalues mb_Znl(n, l, Xn(k), Yn(k), ...
	             double(P(k))/sum(P))] ;
    end
  end
end
et
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
 
% mb_imgmoments.m
function moment = mb_imgmoments(image, x, y)
% MB_IMGMOMENTS(IMAGE, X, Y) calculates the moment MXY for IMAGE
% MB_IMGMOMENTS(IMAGE, X, Y), 
%    where IMAGE is the image to be processed and X and Y define
%    the order of the moment to be calculated. For example, 
%    MB_IMGMOMENTS(IMAGE,0,1) calculates the first order moment 
%    in the y-direction, and 
%    MB_IMGMOMENTS(IMAGE,0,1)/MB_IMGMOMENTS(IMAGE,0,0) is the 
%    'center of mass (fluorescence)' in the y-direction
%
% 10 Aug 98 - M.V. Boland
 
% $Id: mb_imgmoments.m,v 1.2 1999/02/17 14:19:56 boland Exp $
 
if nargin ~= 3
	error('Please supply all three arguments (IMAGE, X, Y)') ;
end
 
%
% Check for a valid image and convert to double precision
%   if necessary.
%
if (isempty(image))
	error('IMAGE is empty.') 
elseif (~isa(image,'double'))
	image = double(image) ;
end
 
%
% Generate a matrix with the x coordinates of each pixel.
%  If the order of the moment in x is 0, then generate
%  a matrix of ones
%
if x==0
	if y==0
		xcoords = ones(size(image)) ;
	end
else 
	xcoords = (ones(size(image,1),1) * ([1:size(image,2)] .^ x)) ;
end
 
%
% Generate a matrix with the y coordinates of each pixel.
%  If the order of the moment in y is 0, then generate
%  a matrix of ones
%
if y~=0
%	ycoords = ones(size(image)) ;
	ycoords = (([1:size(image,1)]' .^ y) * ones(1,size(image,2))) ;
end
 
%
% Multiply the x and y coordinate values together
%
if y==0
	xycoords = xcoords ;
elseif x==0
	xycoords = ycoords ;
else
	xycoords = xcoords .* ycoords ;
end
 
%
% The moment is the double sum of the xyf(x,y)
%
moment = sum(sum(xycoords .* image)) ;
j'ai essayé d'exécuter ce programme, mais j'ai eu ces erreur:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
??? Error using ==> times
Matrix dimensions must agree.
 
Error in ==> mb_imgmoments at 66
moment = sum(sum(xycoords .* image)) ;
 
Error in ==> mb_zernike at 32
Xn = (X-mb_imgmoments(I,1,0)/mb_imgmoments(I,0,0))/R ;
et je ne comprends pas exactement c quoi cette erreur.
j'ai besoin d'aide et je compte sur votre bienveillance.
merci d'avance