{site_name}

{site_name}

🌜 搜索

Imagick::subImageMatch is a function in

php 𝄐 0
phpimagick完整安装
Imagick::subImageMatch is a function in PHP's Imagick extension that allows you to perform template matching on images. Template matching is a technique used in image processing to find a small image (the template) within a larger image.

To use Imagick::subImageMatch, you need to provide a template image and a search image. The function will compare the template image with the search image and find the best match.

Here is an example of how to use Imagick::subImageMatch:

php
$imagick = new Imagick();
$imagick->readImage('search_image.jpg');
$template = new Imagick();
$template->readImage('template_image.jpg');

$result = $imagick->subImageMatch($template);

if ($result !== false) {
foreach ($result['confidence'] as $conf) {
echo "Template found with confidence: " . $conf . "\n";
}
} else {
echo "Template not found.\n";
}


In this example, the search_image.jpg is the image in which we want to find the template_image.jpg. The function will return an array of results with the confidence of each match found. If no match is found, it will return false.

Note that you need to have the Imagick extension installed and enabled in your PHP configuration for this code to work.