ImagickKernel::addUnityKernel

(PECL imagick >= 3.3.0)

ImagickKernel::addUnityKernelAñade un núcleo Unity a la lista de núcleos

Descripción

public ImagickKernel::addUnityKernel(float $scale): void

Añade una cantidad dada del núcleo de convolución 'Unity' al núcleo de convolución pre-escalado y normalizado dado. Esto tiene como efecto añadir esta cantidad de la imagen original en el núcleo de convolución resultante. El efecto resultante es convertir los núcleos definidos en desenfoques suaves mezclados, en núcleos no afilados o en núcleos de nitidez.

Parámetros

Esta función no tiene parámetros.

Valores devueltos

Ejemplos

Ejemplo #1 ImagickKernel::addUnityKernel()

<?php



function renderKernelTable($matrix) {
$output = "<table class='infoTable'>";

foreach (
$matrix as $row) {
$output .= "<tr>";
foreach (
$row as $cell) {
$output .= "<td style='text-align:left'>";
if (
$cell === false) {
$output .= "false";
}
else {
$output .= round($cell, 3);
}
$output .= "</td>";
}
$output .= "</tr>";
}

$output .= "</table>";

return
$output;
}

$matrix = [
[-
1, 0, -1],
[
0, 4, 0],
[-
1, 0, -1],
];

$kernel = \ImagickKernel::fromMatrix($matrix);
$kernel->scale(1, \Imagick::NORMALIZE_KERNEL_VALUE);
$output = "Before adding unity kernel: <br/>";
$output .= renderKernelTable($kernel->getMatrix());
$kernel->addUnityKernel(0.5);
$output .= "After adding unity kernel: <br/>";
$output .= renderKernelTable($kernel->getMatrix());

$kernel->scale(1, \Imagick::NORMALIZE_KERNEL_VALUE);
$output .= "After renormalizing kernel: <br/>";
$output .= renderKernelTable($kernel->getMatrix());

echo
$output;

?>

Ejemplo #2 ImagickKernel::addUnityKernel()

<?php
function addUnityKernel($imagePath) {

$matrix = [
[-
1, 0, -1],
[
0, 4, 0],
[-
1, 0, -1],
];

$kernel = ImagickKernel::fromMatrix($matrix);

$kernel->scale(4, \Imagick::NORMALIZE_KERNEL_VALUE);
$kernel->addUnityKernel(0.5);

$imagick = new \Imagick(realpath($imagePath));
$imagick->filter($kernel);
header("Content-Type: image/jpg");
echo
$imagick->getImageBlob();

}

?>

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top