Function PSNR
Function PSNR
var
mse, k: real;
c: longword;
begin
mse := 0;
k := 1 / length;
for c := 0 to (length - 1) do
mse := mse + Sqr(a[c] - b[c]);
mse := mse * k;
if mse > 0 then
Result := 10 * log10(sqr(255) / mse)
else
Result := 100;
end;
M := (W-2*L)*(H-2*L);
for x := L to W-1-L do
for y := L to H-1-L do
begin
Result.R := Result.R + sqr(Red(I.Pixels[x, y]) - Red(I1.Pixels[x,
y]));
Result.G := Result.G + sqr(Green(I.Pixels[x, y]) - Green(I1.Pixels[x,
y]));
Result.B := Result.B + sqr(Blue(I.Pixels[x, y]) - Blue(I1.Pixels[x,
y]));
end;
if M <> 0 then
begin
Result.R := Result.R / M;
Result.G := Result.G / M;
Result.B := Result.B / M;
end
else
begin // indicates an arror. M = 0
Result.R := -1;
Result.G := -1;
Result.B := -1;
end;
end;