Salut !!
J'ai un autre problème
J'essaye d'écrire un programme de binarisation par la méthode d'otsu:
ça ne marche pas à cause des indices qui commencent par 0 dans ce programme la valeur 0 "noir" est indispensable alors comment faire ?
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 for i=0:255 hist(i)=0; end; for i=1:Hauteur for j=1:Largeur hist(img(i,j))=hist(img(i,j))+1; end; end; for i=0:255 prob(i)=hist/(Hauteur*Largeur); end; omega(0)=prob(0); myu(0)=0; for i=1:255 omega(i)=omega(i-1)+prob(i); myu(i)=myu(i-1)+ i*prob(i); end; seuil=0; max_sigma=0; for i=0:254 if(omega(i)~= 0 & omega (i)~=1) sigma(i)=power(myu(255)*omega(i)-myu(i),2)/(omega(i)*(1- omega(i))); else sigma(i)=0; end; if(sigma(i)>max_sigma) max_sigma=sigma(i); seuil=i; end; end;
A+
Partager