PHP 中的 imageconvolution() 函数
phpprogrammingserver side programming更新于 2025/7/6 4:37:17
imageconvolution() 函数
语法
bool imageconvolution (img, matrix, div, offset )
参数
img:使用 imagecreatetruecolor() 函数创建图像。
matrix:一个 3x3 矩阵是由三个浮点数数组组成的数组。
div:卷积结果的除数,用于归一化。
offset:颜色偏移量。
返回
imageconvolution() 函数在成功时返回 True,否则返回 False失败。
示例
以下是示例
<?php
$img = imagecreatefromgif('https://www.tutorialspoint.com/images/html.gif');
$arr = array(array(2, 0, 1), array(-1, -1, 0), array(0, 0, -1));
imageconvolution($img, $arr, 1, 127);
header('Content-Type: image/png');
imagepng($img, null, 9);
?>
输出
以下是输出 −

示例
让我们看另一个对同一张图片使用不同参数值的示例。现在您可以轻松发现差异:
<?php
$img = imagecreatefromgif('https://www.tutorialspoint.com/images/html.gif');
$arr = array(array(3, 2, 1), array(0, 1, 0), array(1, -1, -1));
imageconvolution($img, $arr, 3, 110);
header('Content-Type: image/png');
imagepng($img, null, 9);
?>
输出
以下是输出 −

