Syntax:float Imagick::getImageChannelDistortion (Imagick $reference, int $channel, int $metric)
Parameters:This function takes three parameters as above and described below: - link:specifies an Imagick object to compare.
- channel:specifies a channel constant valid for your channel mode. To apply more than one channel, combine the channel type constants using bitwise operators.
- metric:specifies one of the metric type constants. The list of metric constants is shown below:
- imagick::METRIC_UNDEFINED (integer)
- imagick::METRIC_MEANABSOLUTEERROR (integer)
- imagick::METRIC_MEANSQUAREERROR (integer)
- imagick::METRIC_PEAKABSOLUTEERROR (integer)
- imagick::METRIC_PEAKSIGNALTONOISERATIO (integer)
- imagick::METRIC_ROOTMEANSQUAREDERROR (integer)
Exceptions:This function will throw an ImagickException on error.Return Value:This function will return TRUE if successful.The following programs illustrate the Imagick::getImageChannelDistortion() functionin PHP:Program 1:
// Create two new imagick objects
$imagick1
=
new
Imagick (
’ https://media.engineerforengineer.org/wp-content/uploads/20190823154611/engineerforengineer24.png ’
);
$imagick2
=
new
Imagick (
’ https://media.engineerforengineer.org/wp-content/uploads/20191112223241/trans9.png ’
);
// Get distortion with constant METRIC as imagick::METRIC_MEANABSOLUTEERROR
$distortion
=
$imagick1
-> getImageChannelDistortion (
$imagick2
, 0, 1);
echo
$distortion
;
?>
Output:122728
Program 2:
// Create two new imagick objects
$imagick1
=
new
Imagick ( ’ https://media.engineerforengineer.org/wp-content/uploads/20190823154611/engineerforengineer24.png ’
);
$imagick2
=
new
Imagick (
’ https://media.engineerforengineer.org/wp-content/uploads/20190823154611/engineerforengineer24.png ’
);
// Get distortion with constant METRIC
// as imagick::METRIC_MEANABSOLUTEERROR
$distortion
=
$imagick1
-> getImageChannelDistortion (
$imagick2
, 0, 1);
echo
$distortion
;
?>
Output:0
Note:The second example displays 0 because both images are the same.Link: https://www.php.net/manual/en/imagick.getimagechanneldistortion.php