search subimage in pre-defined region of a large image
Posted: 2018-03-20T13:22:05-07:00
Hallo!
I would like to implement a fast way to get the position (XY-coordinates) of a defined subimage in a large image. I find ImageMagick to be a quite professional and versatile tool, while this forum offers very good feedback!
The subimage is usually an arbitrary printed mark that is located at pre-defined areas at the corner of a large image. (After getting the coordinates of three of those marks I than cut the image to get the "normalized" content of the scanned paper.)
subimage:
http://maketwowishes.ddns.net/content_static/justUR.tif
The actual size of an original large image is about 2340x3500 pixel, 1-bit b/w tiff-image, and derives from big amounts (10.000+) of scanned pages.
Sample (bottom-right area) of a large image:
http://maketwowishes.ddns.net/content_s ... sample.tif
I have been successful to get the coordinates with the following command line (Linux, ImageMagick 6.9.7-4 Q16 x86_64):
Threshold is necessary since the scanned marks differ slightly (pixel-wise) from each other.
To speed up the process I would like to crop the corner of the large image in order to only subimage-search that area on-the-fly. To avoid unnecessary I/O operations I would like to use a virtual image (w/o acutal writing it to file).
PerlMagick seems fit to that task.
Unfortunately that interface does not seem to have the compare -subimage-search method.
I would like to implement a fast way to get the position (XY-coordinates) of a defined subimage in a large image. I find ImageMagick to be a quite professional and versatile tool, while this forum offers very good feedback!
The subimage is usually an arbitrary printed mark that is located at pre-defined areas at the corner of a large image. (After getting the coordinates of three of those marks I than cut the image to get the "normalized" content of the scanned paper.)
subimage:
http://maketwowishes.ddns.net/content_static/justUR.tif
The actual size of an original large image is about 2340x3500 pixel, 1-bit b/w tiff-image, and derives from big amounts (10.000+) of scanned pages.
Sample (bottom-right area) of a large image:
http://maketwowishes.ddns.net/content_s ... sample.tif
I have been successful to get the coordinates with the following command line (Linux, ImageMagick 6.9.7-4 Q16 x86_64):
Code: Select all
compare -subimage-search -metric RMSE -similarity-threshold 0.3 -dissimilarity-threshold 1.0 S10_sample.tif justUR.tif null: 2>&1
To speed up the process I would like to crop the corner of the large image in order to only subimage-search that area on-the-fly. To avoid unnecessary I/O operations I would like to use a virtual image (w/o acutal writing it to file).
PerlMagick seems fit to that task.
Unfortunately that interface does not seem to have the compare -subimage-search method.
- Is there an equivalent PerlMagick method?
- Is there a way of streaming in shell? Like e.g. so (does not work, just to illustrate the idea):
Code: Select all
convert S10.tif -crop 230x300+2100+3200 - | compare -subimage-search -metric RMSE -similarity-threshold 0.3 -dissimilarity-threshold 1.0 - justUR.tif null: 2>&1
- What are the options to further speed up the process - preferably to <= 1s ? Different algorithm/ strategy/ tool?
- Is the Q8-Version of IM more appropriate in terms of speed for this task?