uTools-Manuals/docs/php/imageconvolution.html
2019-04-28 19:00:34 +08:00

143 lines
10 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>用系数 div 和 offset 申请一个 3x3 的卷积矩阵</title>
</head>
<body class="docs"><div id="layout">
<div id="layout-content"><div id="function.imageconvolution" class="refentry">
<div class="refnamediv">
<h1 class="refname">imageconvolution</h1>
<p class="verinfo">(PHP 5 &gt;= 5.1.0, PHP 7)</p><p class="refpurpose"><span class="refname">imageconvolution</span> &mdash; <span class="dc-title">用系数 div 和 offset 申请一个 3x3 的卷积矩阵</span></p>
</div>
<div class="refsect1 description" id="refsect1-function.imageconvolution-description">
<h3 class="title">说明</h3>
<div class="methodsynopsis dc-description">
<span class="methodname"><strong>imageconvolution</strong></span>
( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$image</code></span>
, <span class="methodparam"><span class="type">array</span> <code class="parameter">$matrix</code></span>
, <span class="methodparam"><span class="type">float</span> <code class="parameter">$div</code></span>
, <span class="methodparam"><span class="type">float</span> <code class="parameter">$offset</code></span>
) : <span class="type">bool</span></div>
<p class="para rdfs-comment">
Applies a convolution matrix on the image, using the given coefficient and
offset.
</p>
</div>
<div class="refsect1 parameters" id="refsect1-function.imageconvolution-parameters">
<h3 class="title">参数</h3>
<p class="para">
<dl>
<dt>
<code class="parameter">image</code></dt>
<dd>
<p class="para">由图象创建函数(例如<span class="function"><a href="imagecreatetruecolor.html" class="function">imagecreatetruecolor()</a></span>)返回的图象资源。</p></dd>
<dt>
<code class="parameter">matrix</code></dt>
<dd>
<p class="para">
A 3x3 matrix: an array of three arrays of three floats.
</p>
</dd>
<dt>
<code class="parameter">div</code></dt>
<dd>
<p class="para">
The divisor of the result of the convolution, used for normalization.
</p>
</dd>
<dt>
<code class="parameter">offset</code></dt>
<dd>
<p class="para">
Color offset.
</p>
</dd>
</dl>
</p>
</div>
<div class="refsect1 returnvalues" id="refsect1-function.imageconvolution-returnvalues">
<h3 class="title">返回值</h3>
<p class="para">
成功时返回 <strong><code>TRUE</code></strong> 或者在失败时返回 <strong><code>FALSE</code></strong>
</p>
</div>
<div class="refsect1 examples" id="refsect1-function.imageconvolution-examples">
<h3 class="title">范例</h3>
<p class="para">
<div class="example" id="example-3671">
<p><strong>Example #1 Embossing the PHP.net logo</strong></p>
<div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$image&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagecreatefromgif</span><span style="color: #007700">(</span><span style="color: #DD0000">'http://www.php.net/images/php.gif'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$emboss&nbsp;</span><span style="color: #007700">=&nbsp;array(array(</span><span style="color: #0000BB">2</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">),&nbsp;array(</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;-</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">),&nbsp;array(</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;-</span><span style="color: #0000BB">1</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">imageconvolution</span><span style="color: #007700">(</span><span style="color: #0000BB">$image</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$emboss</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">127</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">'Content-Type:&nbsp;image/png'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">imagepng</span><span style="color: #007700">(</span><span style="color: #0000BB">$image</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">null</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">9</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
</div>
<div class="example-contents"><p>以上例程会输出:</p></div>
<div class="mediaobject">
<div class="imageobject">
<img src="images/21009b70229598c6a80eef8b45bf282b-imageconvolution_emboss.png" alt="Output of example : Embossing the PHP.net logo" width="120" height="67" />
</div>
</div>
</div>
<div class="example" id="example-3672">
<p><strong>Example #2 Gaussian blur</strong></p>
<div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$image&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">imagecreatetruecolor</span><span style="color: #007700">(</span><span style="color: #0000BB">180</span><span style="color: #007700">,</span><span style="color: #0000BB">40</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Writes&nbsp;the&nbsp;text&nbsp;and&nbsp;apply&nbsp;a&nbsp;gaussian&nbsp;blur&nbsp;on&nbsp;the&nbsp;image<br /></span><span style="color: #0000BB">imagestring</span><span style="color: #007700">(</span><span style="color: #0000BB">$image</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">5</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">10</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">8</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'Gaussian&nbsp;Blur&nbsp;Text'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0x00ff00</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$gaussian&nbsp;</span><span style="color: #007700">=&nbsp;array(array(</span><span style="color: #0000BB">1.0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2.0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1.0</span><span style="color: #007700">),&nbsp;array(</span><span style="color: #0000BB">2.0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">4.0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2.0</span><span style="color: #007700">),&nbsp;array(</span><span style="color: #0000BB">1.0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2.0</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">1.0</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">imageconvolution</span><span style="color: #007700">(</span><span style="color: #0000BB">$image</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$gaussian</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">16</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Rewrites&nbsp;the&nbsp;text&nbsp;for&nbsp;comparison<br /></span><span style="color: #0000BB">imagestring</span><span style="color: #007700">(</span><span style="color: #0000BB">$image</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">5</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">10</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">18</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'Gaussian&nbsp;Blur&nbsp;Text'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0x00ff00</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">'Content-Type:&nbsp;image/png'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">imagepng</span><span style="color: #007700">(</span><span style="color: #0000BB">$image</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">null</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">9</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
</div>
<div class="example-contents"><p>以上例程会输出:</p></div>
<div class="mediaobject">
<div class="imageobject">
<img src="images/21009b70229598c6a80eef8b45bf282b-imageconvolution_gaussian.png" alt="Output of example : Gaussian blur" width="180" height="40" />
</div>
</div>
</div>
</p>
</div>
<div class="refsect1 notes" id="refsect1-function.imageconvolution-notes">
<h3 class="title">注释</h3>
<blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">此函数仅在与 GD 库捆绑编译的 PHP 版本中可用。</span></p></blockquote>
</div>
<div class="refsect1 seealso" id="refsect1-function.imageconvolution-seealso">
<h3 class="title">参见</h3>
<p class="para">
<ul class="simplelist">
<li class="member"><span class="function"><a href="imagefilter.html" class="function" rel="rdfs-seeAlso">imagefilter()</a> - 对图像使用过滤器</span></li>
</ul>
</p>
</div>
</div></div></div></body></html>