Page 1 of 1
stitching or merging scrolled webpages
Posted: 2011-06-05T09:38:15-07:00
by eddieadams
What would be the best approach to stitch or merge multiple screenshots of the same webpage but with a different position? To clearify: let's say there is a webpage which take up three screenshots to match the full height. One for the top of the page, one for the middle and one for the bottom of the page. Each screenshot has some overlapping area with the neighbouring screenshots. The size of this area may differ.
Re: stitching or merging scrolled webpages
Posted: 2011-06-05T11:40:08-07:00
by fmw42
There is no automated way in IM currently. The best method I can think of (assuming no scale or rotation changes) is
Crop out an overlap area in the lower image and use the compare function to find where it best matches in the upper image. Do the same with the bottom and middle image. Then use -mosaic to combine them with the given coordinates using -page.
see
http://www.imagemagick.org/script/compare.php
http://www.imagemagick.org/script/comma ... age-search
http://www.imagemagick.org/Usage/compare/
viewtopic.php?f=1&t=14613&p=51076&hilit ... ric#p51076
http://www.imagemagick.org/Usage/layers/#mosaic
You can also use feathered masks to combine the images so that there is no hard line of division. see
http://www.imagemagick.org/Usage/layers/#layer_prog
http://www.fmwconcepts.com/imagemagick/ ... composite1
http://www.fmwconcepts.com/imagemagick/ ... rlap_blend
You might also let us know your version of IM and platform as compare has had some changes over time and releases.
Re: stitching or merging scrolled webpages
Posted: 2011-06-05T14:05:25-07:00
by eddieadams
Version: ImageMagick 6.2.8 10/20/10 Q16 on Centos 5.x
The -subimage-search option seems interesting but it is not recognized (compare: unrecognized option `-subimage-search'.).
Do i need to update IM?
Re: stitching or merging scrolled webpages
Posted: 2011-06-05T14:49:51-07:00
by fmw42
eddieadams wrote:Version: ImageMagick 6.2.8 10/20/10 Q16 on Centos 5.x
The -subimage-search option seems interesting but it is not recognized (compare: unrecognized option `-subimage-search'.).
Do i need to update IM?
Yes as that old a version of IM did not even have the ability to do a compare with two different size images. The subimage-search was added even later when it was decided that the default should be to just compare two equal sized images. See the changelog for when these changes took place. But I am positive you cannot use such an old version of IM.
2010-08-13 6.6.3-6 Cristy <quetzlzacatenango@image...>
Add -subimage-search option to the compare utility.
2009-03-25 6.5.0-9 Cristy <quetzlzacatenango@image...>
Enhance the compare program to locate a template image within a larger image.
Re: stitching or merging scrolled webpages
Posted: 2011-06-05T19:53:45-07:00
by anthony
Stitching a scrolled image should be much simplier than the more typical 'panorama' stitching.
All that you really want to do is find the one offset number, and then use layers -mosaic to merge them into a auot-expanding canvas.
One way may be a sub-image search of a snall (non-blank) strip of the second image on the first image. "compare" will then give you a simple single column pixel image of posible matches.
The speed of the compare is the tricky aspect. You could cut down the search by cropping both images to a small column of pixels say from 1/3 the way across. A column is less likely to be 'blank' than a row!
Re: stitching or merging scrolled webpages
Posted: 2011-06-06T11:38:48-07:00
by eddieadams
Well on another box i have
Version: ImageMagick 6.6.9-1 2011-03-30 Q16
http://www.imagemagick.org
But no success
compare: image size differs `filename.tif' @ error/compare.c/SimilarityIm
On the Centos 5.5 I update ImageMagick, now I can't seem to use png's but it does have tif support
Version: ImageMagick 6.7.0-3 2011-06-04 Q16
http://www.imagemagick.org
Still no success
compare: image size differs `filename.tif' @ error/compare.c/SimilarityImage/1883.
What version do i need?
Re: stitching or merging scrolled webpages
Posted: 2011-06-06T12:36:51-07:00
by fmw42
Those versions are fine, but you need to specify the correct syntax. Take my example at
viewtopic.php?f=1&t=14613&p=51076#p51076 and update the syntax to include -subimage-search
compare -metric rmse -subimage-search largeimage smallimage resultimages
for example:
compare -metric rmse -subimage-search mandril3.jpg mandril3_156_22.jpg mandril3_similarity2.png
returns two images mandril3_similarity2-0.png and mandril3_similarity2-1.png, the second is the match score image where brighter is a closer match location
it also returns the best match as 0 (0) @ 156,22
0 means rmse=0 or perfect match and the location is at pixel 156,22 (which is where the subsection was chosen for the small image)