I will add something else. compare is very slow for large images. So there are two things you can do:
1) Use multi-resolution processing. That is, scale the images down and do a compare. Get the coordinates and scale them up. Then crop the large image at those coordinates plus some buffer and do a full resolution compare.
Here is an example (unix syntax) for doing that and then the above processing using the same images.
First we extend the one image with gray to make it larger so that -subimage-search is needed for the compare
Code: Select all
convert People.jpg -gravity center -background gray -extent 750x750 People_big.jpg
Next we scale the images down to 1/4 size and do the compare and scale up the coordinates by 4
Code: Select all
coords=`convert People_big.jpg People2.jpg -resize 25% miff:- |\
compare -metric rmse -subimage-search - null: 2>&1 | tr -cs "0-9.," " " | sed 's/ [ ]*/ /g' | cut -d\ -f3`
xx=`echo "$coords" | cut -d, -f1`
yy=`echo "$coords" | cut -d, -f2`
xx=$((4*xx-10))
yy=$((4*yy-10))
ww=520
hh=520
Then we crop the large image at those coordinates plus some buffer (10 on all sides) and compare again. Note, it probably would have been better to make the buffer a multiple of scale, so perhaps 16 or 20, or the equivalent of 4 or 5 pixels at the scaled down size)
Code: Select all
coords=`convert People_big.jpg -crop ${ww}x${hh}+${xx}+${yy} +repage miff:- |\
compare -metric rmse -subimage-search - People2.jpg null: 2>&1 | tr -cs "0-9.," " " | sed 's/ [ ]*/ /g' | cut -d\ -f3`
xx2=`echo "$coords" | cut -d, -f1`
yy2=`echo "$coords" | cut -d, -f2`
ww2=500
hh2=500
xx2=$((xx2+xx))
yy2=$((yy2+yy))
Then we crop the large image to the same size as the small image at those coordinates and do the difference processing with the threshold.
Code: Select all
convert People_big.jpg -crop ${ww2}x${hh2}+${xx2}+${yy2} +repage \
\( -clone 0 People2.jpg -compose difference -composite \
-threshold 5% -fill red -opaque white -transparent black \) \
-compose over -composite people_compare3.png
Note that snibgo's web site at
http://im.snibgo.com/ has similar processing scripts as above for Windows.
2) One can use my FFT correlation scripts, normcrosscorr or rmsecorr, if you are on Linux, Mac OSX or Windows with Cygwin and have IM compiled in HDRI mode (default for IM 7). See my links below. Those will speed up the full resolution compare by about 2 orders of magnitude. Then do the difference processing as above. See my link below for the scripts and more details at
http://www.fmwconcepts.com/imagemagick/ ... mcrosscorr and the paper linked below that.
NOTE: it is always a good idea to identify your IM versions and platform when asking questions on this forum, since syntax may differ.