array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'fr', ), 'this' => array ( 0 => 'function.imageconvolution.php', 1 => 'imageconvolution', ), 'up' => array ( 0 => 'ref.image.php', 1 => 'Fonctions GD et images', ), 'prev' => array ( 0 => 'function.imagecolortransparent.php', 1 => 'imagecolortransparent', ), 'next' => array ( 0 => 'function.imagecopy.php', 1 => 'imagecopy', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'fr', 'path' => 'reference/image/functions/imageconvolution.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5 >= 5.1.0, PHP 7, PHP 8)
imageconvolution — Applique une matrice de la convolution 3x3, en utilisant le coefficient et l'excentrage
imageconvolution() applique une matrice de la convolution
3x3, en utilisant le coefficient div
et l'excentrage
offset
.
image
Un objet GdImage, retournée par une des fonctions de création d'images, comme imagecreatetruecolor().
matrix
Une matrice 3x3 : un tableau contenant trois tableaux de trois nombres à virgules flottantes.
divisor
Le diviseur du résultat de la convolution, utilisé pour la normalisation.
offset
La position de la couleur.
Version | Description |
---|---|
8.0.0 |
image attend une instance de GdImage désormais;
auparavant, une resource gd était attendue.
|
Exemple #1 Impression du logo PHP.net avec imageconvolution()
<?php
$image = imagecreatefromgif('http://www.php.net/images/php.gif');
$emboss = array(array(2, 0, 0), array(0, -1, 0), array(0, 0, -1));
imageconvolution($image, $emboss, 1, 127);
header('Content-Type: image/png');
imagepng($image, null, 9);
?>
L'exemple ci-dessus va afficher :
Exemple #2 Flou gaussien avec imageconvolution()
<?php
$image = imagecreatetruecolor(180,40);
// Écrit le texte et applique un floue gaussien sur l'image
imagestring($image, 5, 10, 8, 'Texte floue goussien', 0x00ff00);
$gaussian = array(array(1.0, 2.0, 1.0), array(2.0, 4.0, 2.0), array(1.0, 2.0, 1.0));
imageconvolution($image, $gaussian, 16, 0);
// Récrit le texte pour la comparaison
imagestring($image, 5, 10, 18, 'Texte floue goussien', 0x00ff00);
header('Content-Type: image/png');
imagepng($image, null, 9);
?>
L'exemple ci-dessus va afficher :