<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.imagick.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'imagick.subimagematch.php',
    1 => 'Imagick::subImageMatch',
    2 => 'Searches for a subimage in the current image and returns a similarity image',
  ),
  'up' => 
  array (
    0 => 'class.imagick.php',
    1 => 'Imagick',
  ),
  'prev' => 
  array (
    0 => 'imagick.stripimage.php',
    1 => 'Imagick::stripImage',
  ),
  'next' => 
  array (
    0 => 'imagick.swirlimage.php',
    1 => 'Imagick::swirlImage',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/imagick/imagick/subimagematch.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="imagick.subimagematch" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Imagick::subImageMatch</h1>
  <p class="verinfo">(PECL imagick 3 &gt;= 3.3.0)</p><p class="refpurpose"><span class="refname">Imagick::subImageMatch</span> &mdash; <span class="dc-title">Searches for a subimage in the current image and returns a similarity image</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-imagick.subimagematch-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>Imagick::subImageMatch</strong></span>(<span class="methodparam"><span class="type"><a href="class.imagick.php" class="type Imagick">Imagick</a></span> <code class="parameter">$Imagick</code></span>, <span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter reference">&$offset</code><span class="initializer"> = ?</span></span>, <span class="methodparam"><span class="type"><a href="language.types.float.php" class="type float">float</a></span> <code class="parameter reference">&$similarity</code><span class="initializer"> = ?</span></span>): <span class="type"><a href="class.imagick.php" class="type Imagick">Imagick</a></span></div>

  <p class="para rdfs-comment">
   Searches for a subimage in the current image and returns a similarity image such that an exact match location is completely white and if none of the pixels match, black, otherwise some gray level in-between.
   You can also pass in the optional parameters bestMatch and similarity. After calling the function similarity will be set to the &#039;score&#039; of the similarity between the subimage and the matching position in the larger image, bestMatch will contain an associative array with elements x, y, width, height that describe the matching region.
  </p>


 </div>


 <div class="refsect1 parameters" id="refsect1-imagick.subimagematch-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt><code class="parameter">Imagick</code></dt>
    <dd>
     <p class="para">
      
     </p>
    </dd>
   
   
    <dt><code class="parameter">offset</code></dt>
    <dd>
     <p class="para">
      
     </p>
    </dd>
   
   
    <dt><code class="parameter">similarity</code></dt>
    <dd>
     <p class="para">
      A new image that displays the amount of similarity at each pixel.
     </p>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-imagick.subimagematch-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   
  </p>
 </div>





 <div class="refsect1 examples" id="refsect1-imagick.subimagematch-examples">
  <h3 class="title">示例</h3>
  <p class="para">
    <div class="example" id="example-3104">
      <p><strong>示例 #1  <span class="function"><strong>Imagick::subImageMatch()</strong></span></strong></p>
      <div class="example-contents">
      <div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">subImageMatch</span><span style="color: #007700">(</span><span style="color: #0000BB">$imagePath</span><span style="color: #007700">) {<br />    </span><span style="color: #0000BB">$imagick </span><span style="color: #007700">= new </span><span style="color: #0000BB">\Imagick</span><span style="color: #007700">(</span><span style="color: #0000BB">realpath</span><span style="color: #007700">(</span><span style="color: #0000BB">$imagePath</span><span style="color: #007700">));<br />    </span><span style="color: #0000BB">$imagick2 </span><span style="color: #007700">= clone </span><span style="color: #0000BB">$imagick</span><span style="color: #007700">;<br />    </span><span style="color: #0000BB">$imagick2</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">cropimage</span><span style="color: #007700">(</span><span style="color: #0000BB">40</span><span style="color: #007700">, </span><span style="color: #0000BB">40</span><span style="color: #007700">, </span><span style="color: #0000BB">250</span><span style="color: #007700">, </span><span style="color: #0000BB">110</span><span style="color: #007700">);<br />    </span><span style="color: #0000BB">$imagick2</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">vignetteimage</span><span style="color: #007700">(</span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">3</span><span style="color: #007700">, </span><span style="color: #0000BB">3</span><span style="color: #007700">);<br /><br />    </span><span style="color: #0000BB">$similarity </span><span style="color: #007700">= </span><span style="color: #0000BB">null</span><span style="color: #007700">;<br />    </span><span style="color: #0000BB">$bestMatch </span><span style="color: #007700">= </span><span style="color: #0000BB">null</span><span style="color: #007700">;<br />    </span><span style="color: #0000BB">$comparison </span><span style="color: #007700">= </span><span style="color: #0000BB">$imagick</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">subImageMatch</span><span style="color: #007700">(</span><span style="color: #0000BB">$imagick2</span><span style="color: #007700">, </span><span style="color: #0000BB">$bestMatch</span><span style="color: #007700">, </span><span style="color: #0000BB">$similarity</span><span style="color: #007700">);<br /><br />    </span><span style="color: #0000BB">$comparison</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setImageFormat</span><span style="color: #007700">(</span><span style="color: #DD0000">'png'</span><span style="color: #007700">);<br />    </span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">"Content-Type: image/png"</span><span style="color: #007700">);<br />    echo </span><span style="color: #0000BB">$imagick</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getImageBlob</span><span style="color: #007700">();<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
      </div>

    </div>
  </p>
 </div>


</div><?php manual_footer($setup); ?>