mirror of
https://github.com/php/doc-ru.git
synced 2026-03-24 15:52:13 +01:00
154 lines
4.2 KiB
XML
154 lines
4.2 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
||
<!-- EN-Revision: 1534707f677267513659e57f530ed5f4cf08f924 Maintainer: sergey Status: ready -->
|
||
<!-- Reviewed: no -->
|
||
<refentry xml:id="imagickkernel.addunitykernel" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||
<refnamediv>
|
||
<refname>ImagickKernel::addUnityKernel</refname>
|
||
<refpurpose>Добавляет ядро Unity в список ядер</refpurpose>
|
||
</refnamediv>
|
||
|
||
<refsect1 role="description">
|
||
&reftitle.description;
|
||
<methodsynopsis>
|
||
<modifier>public</modifier> <type>void</type><methodname>ImagickKernel::addUnityKernel</methodname>
|
||
<methodparam><type>float</type><parameter>scale</parameter></methodparam>
|
||
</methodsynopsis>
|
||
<para>
|
||
Добавляет указанное количество свёрточного ядра 'Unity' к указанному предварительно масштабированному
|
||
и нормализованному ядру. Это фактически добавляет то количество исходного изображения
|
||
в получающееся ядро свёртки. В результате получается преобразование
|
||
определённых ядер в смешанные мягкие пятна, нерезкие ядра или в заострённые ядра.
|
||
</para>
|
||
|
||
</refsect1>
|
||
|
||
<refsect1 role="parameters">
|
||
&reftitle.parameters;
|
||
&no.function.parameters;
|
||
</refsect1>
|
||
|
||
<refsect1 role="returnvalues">
|
||
&reftitle.returnvalues;
|
||
<para>
|
||
|
||
</para>
|
||
</refsect1>
|
||
|
||
|
||
|
||
|
||
<refsect1 role="examples">
|
||
&reftitle.examples;
|
||
<para>
|
||
<example>
|
||
<title>Пример использования <function>ImagickKernel::addUnityKernel</function></title>
|
||
<programlisting role="php">
|
||
<![CDATA[
|
||
<?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 = "Перед добавлением unity ядра: <br/>";
|
||
$output .= renderKernelTable($kernel->getMatrix());
|
||
$kernel->addUnityKernel(0.5);
|
||
$output .= "После добавления unity ядра: <br/>";
|
||
$output .= renderKernelTable($kernel->getMatrix());
|
||
|
||
|
||
$kernel->scale(1, \Imagick::NORMALIZE_KERNEL_VALUE);
|
||
$output .= "После перенормировки ядра: <br/>";
|
||
$output .= renderKernelTable($kernel->getMatrix());
|
||
|
||
echo $output;
|
||
|
||
?>
|
||
]]>
|
||
</programlisting>
|
||
</example>
|
||
|
||
<example>
|
||
<title>Пример использования <function>ImagickKernel::addUnityKernel</function></title>
|
||
<programlisting role="php">
|
||
<![CDATA[
|
||
<?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();
|
||
|
||
}
|
||
|
||
?>
|
||
]]>
|
||
</programlisting>
|
||
</example>
|
||
</para>
|
||
</refsect1>
|
||
|
||
</refentry>
|
||
<!-- Keep this comment at the end of the file
|
||
Local variables:
|
||
mode: sgml
|
||
sgml-omittag:t
|
||
sgml-shorttag:t
|
||
sgml-minimize-attributes:nil
|
||
sgml-always-quote-attributes:t
|
||
sgml-indent-step:1
|
||
sgml-indent-data:t
|
||
indent-tabs-mode:nil
|
||
sgml-parent-document:nil
|
||
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
||
sgml-exposed-tags:nil
|
||
sgml-local-catalogs:nil
|
||
sgml-local-ecat-files:nil
|
||
End:
|
||
vim600: syn=xml fen fdm=syntax fdl=2 si
|
||
vim: et tw=78 syn=sgml
|
||
vi: ts=1 sw=1
|
||
-->
|