9 { 0.299, 0.587, 0.114, 0 },
10 {-0.168736, -0.331264, 0.5, 0.5 },
11 { 0.5, -0.418688, -0.081312, 0.5 },
14 { 0, -0.34414, 1.772, -0.5 },
15 { 1.402, -0.71414, 0, -0.5 }
18 {1,0,0,0}, {0,1,0,0}, {0,0,1,0},
19 {1,0,0,0}, {0,1,0,0}, {0,0,1,0}
22 vector
<Real
> getPSNR(const QImage
&a
,const QImage
&b
) {
23 int width
= a
.width(), height
= a
.height();
26 long sum
, sumR
, sumG
, sumB
;
27 sum
= sumR
= sumG
= sumB
= 0;
28 for (y
=0; y
<height
; ++y
) { /// \todo using walkers instead?
29 line1
= (QRgb
*)a
.scanLine(y
);
30 line2
= (QRgb
*)b
.scanLine(y
);
31 for (x
=0; x
<width
; ++x
) {
32 sum
+= sqr( getGray(line1
[x
]) - getGray(line2
[x
]) );
33 sumR
+= sqr( qRed(line1
[x
]) - qRed(line2
[x
]) );
34 sumG
+= sqr( qGreen(line1
[x
]) - qGreen(line2
[x
]) );
35 sumB
+= sqr( qBlue(line1
[x
]) - qBlue(line2
[x
]) );
38 vector
<Real
> result(4);
43 Real mul
= Real(width
*height
) * Real(sqr(255));
44 for (vector
<Real
>::iterator it
=result
.begin(); it
!=result
.end(); ++it
)
45 *it
= Real(10) * log10(mul
/ *it
);