HomeImagickImagickDrawImagickPixelImagick Pixel IteratorImagick KernelDevelopmentTutorial Source codeReport an issue
Category
Example

separate

← scale  
Separates a linked set of kernels and returns an array of ImagickKernels.
Separates a linked set of kernels and returns an array of ImagickKernels.

Kernel 0
-10-1
040
-10-1

Kernel 1
falsefalse1falsefalse
false111false
11111
false111false
falsefalse1falsefalse

Example

$matrix = [
    [-1, 0, -1],
    [0, 4, 0],
    [-1, 0, -1],
];
$kernel = \ImagickKernel::fromMatrix($matrix);
$kernel->scale(4, \Imagick::NORMALIZE_KERNEL_VALUE);
$diamondKernel = \ImagickKernel::fromBuiltIn(
    \Imagick::KERNEL_DIAMOND,
    "2"
);
$kernel->addKernel($diamondKernel);
$kernelList = $kernel->separate();
$output = '';
$count = 0;
foreach ($kernelList as $kernel) {
    $output .= "<br/>Kernel $count<br/>";
    $output .= Display::renderKernelTable($kernel->getMatrix());
    $count++;
}
return $output;