ImagickKernel::addUnityKernel

(PECL imagick >= 3.3.0)

ImagickKernel::addUnityKernelDescription

Descripción

public ImagickKernel::addUnityKernel ( void ) : void

Añade una cantidad dada de Núcleo de Convolución 'Unidad' al núcleo («kernel») preescalado y normalizado dado. En efecto, esto añade dicha cantidad de la imagen original al núcleo de convolución resultante. El efecto resultante es convertir los núcleos definidos a núcleos no nítidos con una suave borrosidad o a núcleos nítidos.

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($cell3);
                }
                
$output .= "</td>";
            }
            
$output .= "</tr>";
        }
    
        
$output .= "</table>";
    
        return 
$output;
    }

    
$matrix = [
        [-
10, -1],
        [ 
04,  0],
        [-
10, -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 = [
        [-
10, -1],
        [ 
04,  0],
        [-
10, -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();

}

?>