📜  PHP |想象一下 getImageChannelDistortions()函数

📅  最后修改于: 2022-05-13 01:56:46.040000             🧑  作者: Mango

PHP |想象一下 getImageChannelDistortions()函数

Imagick::getImageChannelDistortions()函数是PHP中的一个内置函数,用于将图像的一个或多个图像通道与重建图像进行比较,并返回指定的失真度量。 getImageChannelDistortion() 和 getImageChannelDIstortions() 之间的区别在于后者不一定接受通道参数,因此它也只能接受两个参数。

句法:

float Imagick::getImageChannelDistortions( Imagick $reference,
             int $metric, int $channel = Imagick::CHANNEL_DEFAULT)

参数:此函数接受三个参数,如上所述,如下所述:

  • $reference:指定image的Imagick对象。
  • $metric:它指定度量类型常量之一。
    METRIC 常量列表如下:
    • 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:指定对通道模式有效的通道常数。使用按位运算运算符组合更多十个一通道类型常量。通道常量的默认值是 Imagick::CHANNEL_DEFAULT。

异常:此函数在出错时抛出 ImagickException。

返回值:此函数返回一个双重描述通道失真。

下面的程序说明了PHP中的Imagick::getImageChannelDistortions()函数

方案一:

getImageChannelDistortions($imagick2, 1);
  
echo $distortion;
?>

输出:

23925

方案二:

getImageChannelDistortions($imagick2, 1);
  
echo $distortion;
?>

输出:

0 because both of the images are same.

方案 3:

getImageChannelDistortions($imagick2, 2);
  
echo $distortion;
?>

输出:

0.048318723480804

参考: https://www. PHP.net/manual/en/imagick.getimagechanneldistortions。 PHP