Re: Image processing in perl
by marto (Cardinal) on Feb 01, 2011 at 20:07 UTC
|
* * * * * *
* * * * * *
* * * * * *
* * * * * *
* * * * * *
* * * * * *
along with a sample image:
* *
* *
And your goal is to discover how many occurrences of the sample image can be found in the source image? If so I don't think that's what ImageMagicks compare is for. If this isn't what you are trying to do please clarify.
| [reply] [d/l] [select] |
|
|
| [reply] |
|
|
You may be right, I'm no ImageMagick expert. OP seems to want a count of the occurances of subimage in the source image. The output from compare with it's -subimage-search method is the best match ofset and another image, which presents OP with another problem as this only seems to work for the first match. Also, I don't think it's output is limited to gif files, that could just be an example. I think the solutions offered by others, Image::Match with it's match method and possibly Imager::Search are more along the lines of what OP requires.
| [reply] [d/l] [select] |
|
|
Hi marto,
You got my point, what i want from perlmagick module.If i can't do it by compare function then please suggest me how can i do it?
| [reply] |
Re: Image processing in perl
by davido (Cardinal) on Feb 02, 2011 at 02:21 UTC
|
Image::Match seems to do what you are asking for, though you would probably need to first convert your bmp's to gif format.
| [reply] |
|
|
As an alternative, Imager::Search, which uses Imager. I've not tried either module, so I don't know which is better...
| [reply] |
|
|
Hi , i am not able to install Image::Match in my system due to some dependencies. like only makefile.pl is present no intaller is present for active perl. Please help me out in installetion process."
| [reply] |
|
|
| [reply] |
|
|
| [reply] |
|
|
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. | [reply] [d/l] |
|
|
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.
| [reply] [d/l] [select] |
|
|
|
|