Skip to content

Commit b8c9003

Browse files
author
Cristy
committed
correct PSNR metric
1 parent 38f4538 commit b8c9003

File tree

1 file changed

+6
-30
lines changed

1 file changed

+6
-30
lines changed

magick/compare.c

+6-30
Original file line numberDiff line numberDiff line change
@@ -1437,59 +1437,35 @@ static MagickBooleanType GetPeakSignalToNoiseRatio(const Image *image,
14371437
exception);
14381438
if ((channel & RedChannel) != 0)
14391439
{
1440-
if ((fabs(distortion[RedChannel]) < MagickEpsilon) ||
1441-
(fabs(distortion[RedChannel]) >= 1.0))
1442-
distortion[RedChannel]=fabs(distortion[RedChannel]) < MagickEpsilon ?
1443-
0.0 : 1.0;
1444-
else
1440+
if (fabs(distortion[RedChannel]) >= MagickEpsilon)
14451441
distortion[RedChannel]=fabs(-10.0*MagickLog10(PerceptibleReciprocal(
14461442
distortion[RedChannel])))/48.1647;
14471443
}
14481444
if ((channel & GreenChannel) != 0)
14491445
{
1450-
if ((fabs(distortion[GreenChannel]) < MagickEpsilon) ||
1451-
(fabs(distortion[GreenChannel]) >= 1.0))
1452-
distortion[GreenChannel]=fabs(distortion[GreenChannel]) <
1453-
MagickEpsilon ? 0.0 : 1.0;
1454-
else
1446+
if (fabs(distortion[GreenChannel]) >= MagickEpsilon)
14551447
distortion[GreenChannel]=fabs(-10.0*MagickLog10(PerceptibleReciprocal(
14561448
distortion[GreenChannel])))/48.1647;
14571449
}
14581450
if ((channel & BlueChannel) != 0)
14591451
{
1460-
if ((fabs(distortion[BlueChannel]) < MagickEpsilon) ||
1461-
(fabs(distortion[BlueChannel]) >= 1.0))
1462-
distortion[BlueChannel]=fabs(distortion[BlueChannel]) < MagickEpsilon ?
1463-
0.0 : 1.0;
1464-
else
1452+
if (fabs(distortion[BlueChannel]) >= MagickEpsilon)
14651453
distortion[BlueChannel]=fabs(-10.0*MagickLog10(PerceptibleReciprocal(
14661454
distortion[BlueChannel])))/48.1647;
14671455
}
14681456
if (((channel & OpacityChannel) != 0) && (image->matte != MagickFalse))
14691457
{
1470-
if ((fabs(distortion[OpacityChannel]) < MagickEpsilon) ||
1471-
(fabs(distortion[OpacityChannel]) >= 1.0))
1472-
distortion[OpacityChannel]=fabs(distortion[OpacityChannel]) <
1473-
MagickEpsilon ? 0.0 : 1.0;
1474-
else
1458+
if (fabs(distortion[OpacityChannel]) >= MagickEpsilon)
14751459
distortion[OpacityChannel]=fabs(-10.0*MagickLog10(PerceptibleReciprocal(
14761460
distortion[OpacityChannel])))/48.1647;
14771461
}
14781462
if (((channel & IndexChannel) != 0) && (image->colorspace == CMYKColorspace))
14791463
{
1480-
if ((fabs(distortion[BlackChannel]) < MagickEpsilon) ||
1481-
(fabs(distortion[BlackChannel]) >= 1.0))
1482-
distortion[BlackChannel]=fabs(distortion[BlackChannel]) <
1483-
MagickEpsilon ? 0.0 : 1.0;
1484-
else
1464+
if (fabs(distortion[BlackChannel]) >= MagickEpsilon)
14851465
distortion[BlackChannel]=fabs(-10.0*MagickLog10(PerceptibleReciprocal(
14861466
distortion[BlackChannel])))/48.1647;
14871467
}
1488-
if ((fabs(distortion[CompositeChannels]) < MagickEpsilon) ||
1489-
(fabs(distortion[CompositeChannels]) >= 1.0))
1490-
distortion[CompositeChannels]=fabs(distortion[CompositeChannels]) <
1491-
MagickEpsilon ? 0.0 : 1.0;
1492-
else
1468+
if (fabs(distortion[CompositeChannels]) >= MagickEpsilon)
14931469
distortion[CompositeChannels]=fabs(-10.0*MagickLog10(PerceptibleReciprocal(
14941470
distortion[CompositeChannels])))/48.1647;
14951471
return(status);

0 commit comments

Comments
 (0)