ImagickKernel::addUnityKernel カーネルリストに Unity カーネルを追加する &reftitle.description; public voidImagickKernel::addUnityKernel floatscale 事前にスケーリングおよび正規化されたカーネルに、指定した量の 'Unity' 畳み込みカーネルを 追加します。これにより、元の画像がその量だけ畳み込みカーネルの結果に加算されます。 結果として、定義されたカーネルをブレンドされたソフトブラー、 アンシャープカーネル、またはシャープニングカーネルに変換できます。 &reftitle.parameters; &no.function.parameters; &reftitle.returnvalues; &reftitle.examples; <function>ImagickKernel::addUnityKernel</function> "; foreach ($matrix as $row) { $output .= ""; foreach ($row as $cell) { $output .= ""; if ($cell === false) { $output .= "false"; } else { $output .= round($cell, 3); } $output .= ""; } $output .= ""; } $output .= ""; 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:
"; $output .= renderKernelTable($kernel->getMatrix()); $kernel->addUnityKernel(0.5); $output .= "After adding unity kernel:
"; $output .= renderKernelTable($kernel->getMatrix()); $kernel->scale(1, \Imagick::NORMALIZE_KERNEL_VALUE); $output .= "After renormalizing kernel:
"; $output .= renderKernelTable($kernel->getMatrix()); echo $output; ?> ]]>
<function>ImagickKernel::addUnityKernel</function> 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(); } ?> ]]>