这个 图像卷积 函数是PHP中的一个内置函数,用于修改图像内容。它使用给定的系数和偏移量在图像中应用3 x 3卷积矩阵。此函数在成功时返回true,失败时返回false。
null
语法:
bool imageconvolution ( $image, $matrix, $div, $offset )
参数: 此函数接受上述四个参数,如下所述:
- $image: 它由一个图像创建函数返回,例如imagecreatetruecolor()。它用于创建图像的大小。
- $matrix: 它包含一个由3 x 3(3 x 3矩阵)个浮点数组成的数组。
- $div: 它是卷积结果的除数,用于归一化。
- $offset: 它用于设置颜色偏移。
返回值: 此函数在成功时返回True,失败时返回False。
下面的程序说明了 图像卷积 PHP中的函数:
项目1:
<?php // Create a gif image $image = imagecreatefromgif( // Declare a 3X3 matrix $matrix = array ( array (2, 0, 0), array (0, -1, 0), array (0, 0, -1) ); // imageconvolution function to modify image elements imageconvolution( $image , $matrix , 1, 127); // Output of image content header( 'Content-Type: image/png' ); imagepng( $image , null, 9); ?> |
输出:
项目2:
<?php // Create a gif image $image = imagecreatefrompng( // Declare a 3X3 matrix $emboss = array ( array (0, -1, 2), array (2, 0, 0), array (2, 0, -2) ); // imageconvolution function to modify image elements imageconvolution( $image , $emboss , 1, 127); // Output of image content header( 'Content-Type: image/png' ); imagepng( $image , null, 9); ?> |
输出:
相关文章:
参考: http://php.net/manual/en/function.imageconvolution.php
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END