1Image::SubImageFind(3)User Contributed Perl DocumentationImage::SubImageFind(3)
2
3
4
6 Image::SubImageFind - Perl extension for locating a sub-image within an
7 image
8
10 use Image::SubImageFind qw/FindSubImage/;
11
12 # First parameter is the larger image file (HayStack)
13 # Second parameter is the sub-image file to locate within the larger image (Needle)
14 my ($x, $y) = FindSubImage("./haystackfile.png", "./needlefile.jpg");
15 if ($x > 0 || $y > 0) {
16 print "Found sub-image at: $x X $y\n";
17 } else {
18 print "Could not find sub-image.\n";
19 }
20
21 # Alternatively, you can use the emerging object oriented syntax.
22 my $finder = new Image::SubImageFind("./haystackfile.png", "./needlefile.png");
23 my ($x, $y) = $finder->GetCoordinates();
24 print "$x X $yn";
25
26 # Another example; which may allow for more flexibility.
27 my $finder = new Image::SubImageFind("./haystackfile.png");
28 my ($x, $y) = $finder->GetCoordinates("./needlefile.png");
29 print "$x X $yn";
30
31 # You can also specify an alternate comparison method. The default is DWVB; which
32 # uses an adaptive filter for the correct localization of subimages.
33 #
34 # Another is called GPC; which is just a generic pixel compare, but also supports a
35 # delta threshold (using GetMaxDelta and SetMaxDelta).
36 use Image::SubImageFind qw/:CONST/;
37
38 my $finder = new Image::SubImageFind("./haystackfile.png", "./needlefile.png", CM_DWVB);
39 # OR
40 my $finder = new Image::SubImageFind("./haystackfile.png", "./needlefile.png", CM_GPC);
41 # $finder->GetMaxDelta();
42 # $finder->SetMaxDelta([DeltaValue]); # 0 or greater, where 0 means no pixel difference
43
45 Perl module to aide in locating a sub-image within an image.
46
47 EXPORT
48 None by default.
49
51 One of the underlying algorithms and originating code by Dr. Werner Van
52 Belle (http://werner.yellowcouch.org/Papers/subimg/index.html)
53
55 Dennis K. Paulsen, <ctrondlp@cpan.org>
56
58 Copyright (C) 2010-2011 by Dennis K. Paulsen
59
60 Other portions are copyright their respective owners.
61
62 This program is free software; you can redistribute it and/or modify it
63 under the terms of the GNU General Public License as published by the
64 Free Software Foundation; version 2 of the License.
65
66
67
68perl v5.30.0 2019-07-26 Image::SubImageFind(3)