PHP Imagick getImageChannelDistortions () function

PHP

Syntax:
float Imagick::getImageChannelDistortions (Imagick $reference, int  $metric, int $channel = Imagick::CHANNEL_DEFAULT)
Parameters:This function takes three parameters as above and described below:
  • $reference:Specifies an Imagick image object.
  • $metric:specifies one of metric type constants
    The list of metric constants is shown below:
    • imagick::METRIC_UNDEFINED (0)
    • imagick::METRIC_MEANABSOLUTEERROR (1)
    • imagick::METRIC_MEANSQUAREERROR (2 )
    • imagick::METRIC_PEAKABSOLUTEERROR (3)
    • imagick::METRIC_PEAKSIGNALTONOISERATIO (4)
    • imagick::METRIC_ROOTMEANSQUAREDERROR (5)
    • $channel:specifies a channel constant valid for channel mode. Use the bitwise operator to combine more than ten constants of the same channel type. The default channel constants are Imagick::CHANNEL_DEFAULT.
    Exceptions:This function will throw an ImagickException on error.Return Value :this function returns a double description of the channel distortion.The following programs illustrate the Imagick::getImageChannelDistortions() 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 / 20190916133223 / diamond.png ` );  
    // Get distortion with constant METRIC as imagick::METRIC_MEANABSOLUTEERROR $distortion = $imagick1 -> getImageChannelDistortions ( $imagick2 , 1); echo $distortion ; ?>
    Output:
    23925
    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 -> getImageChannelDistortions ( $imagick2 , 1); echo $distortion ; ?>
    Output:
    0 because both of the images are same.
    Program 3: < ? php  
    // 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 / 20190916133633 / gausian.png ` );  
    // Get distortion with constant METRIC as imagick::METRIC_MEANSQUAREERROR $distortion = $imagick1 -> getImageChannelDistortions ( $imagick2 , 2); echo $distortion ; ?>
    Output:
    0.048318723480804
    Link: https:// www .php.net / manual / en / imagick.getimagechanneldistortions.php



Get Solution for free from DataCamp guru