छवि रूपांतरण () PHP में एक इनबिल्ट फ़ंक्शन है जिसका उपयोग छवि में गुणांक और ऑफ़सेट का उपयोग करके 3×3 कनवल्शन मैट्रिक्स को लागू करने के लिए किया जाता है।
सिंटैक्स
bool imageconvolution ( $image, $matrix, $div, $offset)
पैरामीटर
छवि रूपांतरण () चार पैरामीटर लेता है:$image, $matrix, $div, और $offset।
-
$छवि - इस पैरामीटर का उपयोग इमेज क्रिएशन फंक्शन जैसे इमेजक्रिएटट्रूकलर () का उपयोग करके इमेज का आकार बनाने के लिए किया जाता है।
-
$मैट्रिक्स - इस पैरामीटर में फ़्लोट्स के 3×3 मैट्रिक्स की एक सरणी होती है।
-
$div - इसका उपयोग सामान्यीकरण के लिए किया जाता है।
-
$ऑफ़सेट - इस पैरामीटर का उपयोग रंग ऑफ़सेट सेट करने के लिए किया जाता है।
रिटर्न वैल्यू
छवि रूपांतरण () सफलता पर सही और असफलता पर गलत लौटाता है।
उदाहरण 1
<?php
// load the PNG image by using imagecreatefrompng function.
$image = imagecreatefrompng('C:\xampp\htdocs\Images\img59.png');
// Applied the 3X3 array matrix
$matrix = array(
array(2, 0, 0),
array(0, -1, 0),
array(0, 0, -1)
);
// imageconvolution function to modify image elements
imageconvolution($image, $matrix, 1, 127);
// show the output image in the browser
header('Content-Type: image/png');
imagepng($image, null, 9);
?> आउटपुट
imageconvolution() फ़ंक्शन का उपयोग करने से पहले PNG छवि इनपुट करें

Imageconvolution() फ़ंक्शन का उपयोग करने के बाद PNG छवि आउटपुट करें

उदाहरण 2
<?php
$image = imagecreatetruecolor(700, 300);
// Writes the text and apply a gaussian blur on the image
imagestring($image, 50, 25, 8, 'Gaussian Blur Text image', 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, 15, 20, 18, 'Gaussian Blur Text image', 0x00ff00);
header('Content-Type: image/png');
imagepng($image, null, 9);
?> आउटपुट
