Bonjour à tous je souhaite pouvoir appliquer des effets de convolution et en ce moment ce sont les matrices LOG "Laplace of Gaussian" pour ce faire je calcul la matrice comme ceci

Code pascal : 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
 
function ComputeGaussian(x, Sigma : Single) : Single;
begin
  Result := System.exp(((-x * x) / ( 2 * Sigma * Sigma)));
end;  
 
function ComputeLoG(x, Sigma : Single) : Single;
var
  g : Single;
begin
  g := ComputeGaussian(x,Sigma);
  Result := (x * x - 2 * Sigma * Sigma) / (Math.power(Sigma,4)) * g;
end;  
 
function ComputeLOGKernel(Var KernelSize : Integer; Weight : Single) : TBZDynSingleArray;
Var
  KernelRadius : Integer;
  x, y , i, j : Integer;
  s, Sum, Dist, Theta, f, xx,yy : Single;
  t, KSize : Integer;
  //OutMatrix : Array of Single;
begin
  s := weight - 0.8;
  // t := Round(3.35 * s + 0.33);
 //KernelSize := 2 * t + 1;
  KernelRadius := KernelSize div 2;
  KSize := KernelSize  * KernelSize;
  SetLength(Result,  KSize );
  Sum := 0;
  Dist := 0;
  for y := -KernelRadius to KernelRadius do
  begin
    j := (y + KernelRadius);
    yy := y; //j - t;
    yy := yy * yy;
    j := j * KernelSize;
    for x := -KernelRadius to KernelRadius do
    begin
      i := x + KernelRadius;
      xx := x; //i - t;
      xx := xx * xx;
      Dist := System.Sqrt(xx + yy);
      f := ComputeLOG(Dist, s);
      Result[j + i] := f;
      Sum := Sum + f;
    end;
  end;
  // normalisation
  Theta := 1.0 / Sum;
  for x := 0 to (KSize-1) do Result[x] := Result[x] * Theta;
end;

Seulement le résultat n'est pas celui au quel je m'attend

Quel est votre avis ? mes calcul sont-ils juste ?

Voici l'image originale de test

Nom : lenna-noisy.png
Affichages : 313
Taille : 167,2 Ko

et le résultat avec une matrice générée de 7x7

Nom : 2020-04-27_093159.png
Affichages : 290
Taille : 221,7 Ko

Merci d'avance pour votre aide

Jérôme