in reply to Re: Image processing in perl
in thread Image processing in perl

Hi, thanks for the suggestion. I installed the Image::Match package. As i told, i have two images, sample image and reference image. there are total 30 occurance of reference image in sample image, but theprogram is giving only one occurence. like "found at 3:424" coordinate.it should give the output for all 30 (x,y) coordinate. the program is given bellow:
use Image::Match; $sample = Prima::Image-> load('im1.gif') or die "Can't load: $@"; $reference = Prima::Image-> load('im2.gif') or die "Can't load: $@"; # find again $OPTIONS{multiple} = 1 ; my ( $x, $y) = $sample-> match( $reference); $OPTIONS{overlap} = all ; print defined($x) ? "found at $x:$y\n" : "not found\n"; print "$x $y";
I am not able to find theway to do the same. Please anyone suggest me how to get the desired output.

Replies are listed 'Best First'.
Re^3: Image processing in perl
by davido (Cardinal) on Feb 03, 2011 at 08:10 UTC

    You should use strict;. Had you done so you would realize that %OPTIONS doesn't exist, which is a clue that your expectation that $OPTIONS{multiple} = 1; is doing something is wrong.

    The POD for that module is simply awful. However, I think if you alter your match() call as follows, you'll have better luck:

    my( @matches ) = $sample->match($reference, {multiple => 1});

    You should find @matches to now be populated with an array of arrays representing the XY coordinates of each match.

    Whoever wrote that POD should be shot though (with a water pistol, of course). I would have to read the module's actual code to be sure that my suggestion even fits.


    Dave

      hi Dave, I tried this one but still same problem. it is showing the o/p only for one occurance. please give me the suitable solution to this problem.

        Well, three suggestions I have: (1) Look at the code of the module itself and determine how it reads the parameters so that you can massage your request to fit within what its method is expecting. (2) Look at the code of the module itself for an example of how to roll your own solution that works as you would prefer it to. (3) If the module's code is broken, get in touch with the module's author and help out by submitting a patch to him.

        Option one or two are probably the easiest. The module's deficient POD does suggest that it's possible to get a list of all matches, so it's probably just a matter of looking at how the module expects you to properly request a list of all matches versus first match only. For that you'll have to take a look at the module's code, as the POD is not thorough enough to explain what is required.


        Dave