Find sub-image position in main-image

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
selvam
Posts: 2
Joined: 2013-09-25T22:06:15-07:00
Authentication code: 6789

Find sub-image position in main-image

Post by selvam »

Hi,

I'am new to ImageMagick.
working on OMR(Optical mark recognition) have two images

1. main-image(tiff)
2. sub-image(tiff)

need to identify the position(x, y) of the sub-image in the main-image.

Need to do it c or c++.

Thanks for any input.

Selvam
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Find sub-image position in main-image

Post by fmw42 »

IM has a function called compare with the -subimage-search option that will do that. You will need to find the equivalent commands in one of the C or C++ APIs.

See
http://www.imagemagick.org/script/compare.php
http://www.imagemagick.org/Usage/compare/
http://www.imagemagick.org/Usage/compare/#statistics
viewtopic.php?f=1&t=14613&p=51076&hilit ... ric#p51076 (need to add -subimage-search now to that example)

http://www.imagemagick.org/script/api.php
selvam
Posts: 2
Joined: 2013-09-25T22:06:15-07:00
Authentication code: 6789

Re: Find sub-image position in main-image

Post by selvam »

Thanks for your valuable inputs.

I have gone through the "compare"(Command line Program) with the -subimage-search option.
but I'am not able to find an equivalent function in c or c++.

The "compare"(Command line Program) returns the best match offset
ie.(Returns Only one best matched Offset Value among the several offset values)

The Following are my requirements :
1 ) All the occurrence of the marker(sub-image) positions in the scanned(main-image) image, must be identified.
2 ) Based on all the occurrence, we need to do Cropping work on the scanned(main-image) image

Thanks in advance

Selvam
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Find sub-image position in main-image

Post by fmw42 »

The Following are my requirements :
1 ) All the occurrence of the marker(sub-image) positions in the scanned(main-image) image, must be identified.
2 ) Based on all the occurrence, we need to do Cropping work on the scanned(main-image) image
The second output image (result-1) will be the match score image. You can search that for all the best matches.

see my script, maxima, at the link below for ideas how to do that.
oxspray
Posts: 1
Joined: 2016-03-09T06:09:03-07:00
Authentication code: 1151

Re: Find sub-image position in main-image

Post by oxspray »

Hello fmw42,

Thanks for your script (maxima).
I also need to extract all subimages positions found in a reference main image.
The main image is a map with different icons (like POI). Sometimes there is several same icons inside the map.
My problem is I don't know how to pass the subimage as parameter in the maxima command or how to use parameters correctly.
Is the maxima script adapted to my request? If yes how can I use it properly?

Thanks!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Find sub-image position in main-image

Post by fmw42 »

My maxima script will find as many matches as you desire or stop when the match score gets too low. It returns each one. The key is to provide the mask region size. The script finds the highest correlation value and its coordinates. Then it masks out that location, Then repeats for the next highest correlation value, etc. Read the documentation about the arguments on the examples page for maxima.
Post Reply