imageconvolution

(PHP 5 >= 5.1.0, PHP 7)

imageconvolution用系数 div 和 offset 申请一个 3x3 的卷积矩阵

说明

imageconvolution ( resource $image , array $matrix , float $div , float $offset ) : bool

Applies a convolution matrix on the image, using the given coefficient and offset.

参数

image

由图象创建函数(例如imagecreatetruecolor())返回的图象资源。

matrix

A 3x3 matrix: an array of three arrays of three floats.

div

The divisor of the result of the convolution, used for normalization.

offset

Color offset.

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

范例

Example #1 Embossing the PHP.net logo

<?php
$image 
imagecreatefromgif('http://www.php.net/images/php.gif');

$emboss = array(array(200), array(0, -10), array(00, -1));
imageconvolution($image$emboss1127);

header('Content-Type: image/png');
imagepng($imagenull9);
?>

以上例程会输出:

Output of example : Embossing the PHP.net logo

Example #2 Gaussian blur

<?php
$image 
imagecreatetruecolor(180,40);

// Writes the text and apply a gaussian blur on the image
imagestring($image5108'Gaussian Blur Text'0x00ff00);
$gaussian = array(array(1.02.01.0), array(2.04.02.0), array(1.02.01.0));
imageconvolution($image$gaussian160);

// Rewrites the text for comparison
imagestring($image51018'Gaussian Blur Text'0x00ff00);

header('Content-Type: image/png');
imagepng($imagenull9);
?>

以上例程会输出:

Output of example : Gaussian blur

注释

Note: 此函数仅在与 GD 库捆绑编译的 PHP 版本中可用。

参见

相关文章
php gd 和图像处理 函数 取得图像类型的文件后缀php gd 和图像处理 函数 取得 getimagesize,exif read data,exif thumbnail,exif imagetype 所返回的图像类型的 mime 类型php gd 和图像处理 函数 以 wbmp 格式将图像输出到浏览器或文件php gd 和图像处理 函数 取得与指定的颜色加透明度最接近的颜色php gd 和图像处理 函数 取得与给定颜色最接近的色度的黑白色的索引php gd 和图像处理 函数 取消图像颜色的分配php gd 和图像处理 函数 用系数 div 和 offset 申请一个 3x3 的卷积矩阵php gd 和图像处理 函数 重采样拷贝部分图像并调整大小php gd 和图像处理 函数 拷贝部分图像并调整大小php gd 和图像处理 函数 新建一个基于调色板的图像php gd 和图像处理 函数 crop an image to the given rectanglephp gd 和图像处理 函数 crop an image automatically using one of the available modesphp gd 和图像处理 函数 使用 freetype 2 字体将文本写入图像php gd 和图像处理 函数 对 gd 图像应用 gamma 修正php gd 和图像处理 函数 converts a palette based image to true colorphp gd 和图像处理 函数 以 png 格式将图像输出到浏览器或文件php gd 和图像处理 函数 set the clipping rectanglephp gd 和图像处理 函数 set the interpolation methodphp gd 和图像处理 函数 将 xbm 图像输出到浏览器或文件php gd 和图像处理 函数 将 png 图像文件转换为 wbmp 图像文件
关注编程学问公众号