이미지 처리 및 GD imageconvolution

(PHP 5 >= 5.1.0, PHP 7, PHP 8)

imageconvolution — 계수 및 오프셋을 사용하여 3x3 합성곱 행렬 적용


설명

imageconvolution(
    GdImage $image,
    array $matrix,
    float $divisor,
    float $offset
): bool
                

주어진 계수와 오프셋을 사용하여 이미지에 컨볼루션 행렬을 적용합니다.


매개변수

image
imagecreatetruecolor()와 같은 이미지 생성 함수 중 하나에서 반환되는 GdImage 객체.
matrix
3x3 행렬: 3개의 부동 소수점 배열 3개로 구성된 배열.
divisor
정규화에 사용되는 컨볼루션 결과의 제수입니다.
offset
색상 오프셋.

반환 값

성공하면 true를, 실패하면 false를 반환합니다.


변경 로그

버전 설명
8.0.0 image는 이제 GdImage 인스턴스를 예상합니다. 이전에는 리소스가 필요했습니다.

Examples

예제 #1 PHP.net 로고 엠보싱

                  
<?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);
?>
                  
                

위의 예는 다음을 출력합니다.

function imageconvolution

예제 #2 Gaussian blur

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

// Writes the text and apply a gaussian blur on the image
imagestring($image, 5, 10, 8, 'Gaussian Blur Text', 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);

// Rewrites the text for comparison
imagestring($image, 5, 10, 18, 'Gaussian Blur Text', 0x00ff00);

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

위의 예는 다음을 출력합니다.

function imageconvolution


기타