Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> PHP

ฟังก์ชัน imageconvolution() ใน PHP


ฟังก์ชัน imageconvolution() ใช้การคอนฟลูชัน (Convolution) กับภาพ โดยใช้ matrix 3x3

ไวยากรณ์

bool imageconvolution (img, matrix, div, offset)

พารามิเตอร์

  • img: ภาพจาก imagecreatetruecolor()
  • matrix: Matrix 3x3 เป็น array ของ 3 arrays ที่มี 3 floats
  • div: ตัวหารสำหรับ normalization
  • offset: ค่า offset ของสี

คืนค่า

True ถ้าสำเร็จ False ถ้าล้มเหลว

ตัวอย่าง

<?php 
$img = imagecreatefromgif('https://www.tutorialspoint.com/images/html.gif'); 
$arr = array(array(2, 0, 1), array(-1, -1, 0), array(0, 0, -1)); 
imageconvolution($img, $arr, 1, 127); 
header('Content-Type: image/png'); 
imagepng($img, null, 9); 
?>

ผลลัพธ์

ฟังก์ชัน imageconvolution() ใน PHP

ตัวอย่างที่ 2

<?php 
$img = imagecreatefromgif('https://www.tutorialspoint.com/images/html.gif'); 
$arr = array(array(3, 2, 1), array(0, 1, 0), array(1, -1, -1)); 
imageconvolution($img, $arr, 3, 110); 
header('Content-Type: image/png'); 
imagepng($img, null, 9); 
?>

ผลลัพธ์

ฟังก์ชัน imageconvolution() ใน PHP