is this the same as a read mask would do? I don't know.
No, as you explain it, it would be more like a write mask. The read mask would only process those pixel defined by the mask. The write mask processes all pixels and then filters by the mask after processing all pixels.
Why can you not use -compose difference and then threshold on some appropriate value?
Sound like you want to compute the rmse values for every pixel in the two images with convert -compose ... -composite, (rather than compare, presumably to do other things in the convert in one command), then threshold the result.
You can compute the rmse difference images from scripting using compose difference on each channel, average the channels and use -evaluate pow 0.5 to compute the sqrt. Then get the average (mean) statistics from that image.
I do something similar only the metric is normalized cross correlation, in my script, simiar, at
http://www.fmwconcepts.com/imagemagick/ ... /index.php
Try this to get the rmse error between the two same size images.
convert image1.png image2.png -compose difference -composite -separate +channel \
-poly "0.3333,2 0.3333,2 0.3333,2" -evaluate pow 0.5 -write rmse.png -format "%[mean] (%[fx:mean])" info:
rmse=sqrt( (r1-r2)^2 + (g1-g2)^2 +(b1-b2)^2) / 3 )
-poly does the squareing, adding and dividing by 3 (i.e multiply each square by 0.3333)
Of course my command line could be made into a new compose method, say -compose rmse and my script could be -compose ncc.
EDIT: Here are the command to do NCC, but it needs to be done in HDRI
ncc=(image1-mean1) * (image2-mean2) / (std1*std2)
infile1="cyclops.gif"
infile2="cyclops.gif"
convert $infile1 -colorspace gray 1tmp1.miff
convert $infile2 -colorspace gray 1tmp2.miff
qrange2=`convert xc: -format "%[fx:quantumrange*quantumrange]" info:`
m1=`convert 1tmp1.miff -format "%[mean]" info:`
m2=`convert 1tmp2.miff -format "%[mean]" info:`
m12=`convert xc: -format "%[fx:$m1*$m2]" info:`
s1=`convert 1tmp1.miff -format "%[standard-deviation]" info:`
s2=`convert 1tmp2.miff -format "%[standard-deviation]" info:`
s12=`convert xc: -format "%[fx:($qrange2)/($s1*$s2)]" info:`
imh convert \( 1tmp1.miff -evaluate subtract $m1 \) \( 1tmp2.miff -evaluate subtract $m2 \) \
-compose multiply -composite -evaluate multiply $s12 \
+write ncc.png -format "%[mean] (%[fx:mean])\n" info:
65535.6 (1.00001)
Note that we have to multiply the result by quantumrange^2. One quantumrange is need to compensate for IM normalizing to the range 0 to 1 before multiplying and unnormalizing the result by multply by quantumrange
(5/quantumrange)*(5/quantumrange)*quantumrange = 25/quantumrange and we need 25.
The other quantumrange in the square is needed because the ncc result in in the range -1 to 1. Thus to get the result of perfect match to be 65535 (1), we must multiply the 1 by quantumrange for the non-normalized result.