(PHP 5 >= 5.1.0, PHP 7)
imageconvolution — Applique une matrice de la convolution 3x3, en utilisant le coefficient et l'excentrage
$image
, array $matrix
, float $div
, float $offset
) : bool
imageconvolution() applique une matrice de la convolution
3x3, en utilisant le coefficient div et l'excentrage
offset.
imageUne ressource d'image, retournée par une des fonctions de création d'images, comme imagecreatetruecolor().
matrixUne matrice 3x3 : un tableau contenant trois tableaux de trois nombres à virgules flottantes.
divLe diviseur du résultat de la convolution, utilisé pour la normalisation.
offsetLa position de la couleur.
Cette fonction retourne TRUE en cas de succès ou FALSE si une erreur survient.
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 :
Cette fonction requière GD 2.1.0 ou supérieur.