Wolfgang,
I have been struggling with doing the same thing on a 3x3 window at
every pixel across the whole image (so the output is the same size as
the input). I tried to put it all in a single command line to avoid
the intermediate images. Anthony pointed out to me that I need to
swap the two images at the end so that I am subtracting correctly
(see +swap). If it helps, here is what I am trying to do, but so far
it does not work right and I suspect that there is a problem with
overflow or clipping still.
Get 3x3 average using convolve
ave3="1,1,1,1,1,1,1,1,1"
convert $infile -convolve "$ave3" $ave
Get variance
convert \( $infile $infile -compose multiply -composite -convolve
"$ave3" \) \( $ave $ave -compose multiply -composite \) +swap
-compose minus -composite $var_cmp
Or Get standard deviation.
convert \( $infile $infile -compose multiply -composite -convolve
"$ave3" \) \( $ave $ave -compose multiply -composite \) +swap
-compose minus -composite -fx "sqrt(u)" $std_cmp
I am still not getting correct results.
I do have another way to do this that does work, but is very slow and
does not apply to your downsizing case.
pixels="aa=p[-1,-1]; ab=p[0,-1]; ac=p[+1,-1]; ba=p[-1,0]; bb=p[0,0];
bc=p[+1,0]; ca=p[-1,+1]; cb=p[0,+1]; cc=p[+1,+1];"
ave="((aa)+(ab)+(ac)+(ba)+(bb)+(bc)+(ca)+(cb)+(cc))/9)"
ave2="((aa*aa)+(ab*ab)+(ac*ac)+(ba*ba)+(bb*bb)+(bc*bc)+(ca*ca)+(cb*cb)+(cc*cc))/9)"
convert $infile -fx "$pixels u=($ave2 - ($ave*$ave))" $var_stat
convert $infile -fx "$pixels u=sqrt($ave2 - ($ave*$ave))" $std_stat
I am pretty sure this works correctly. But I do not know how to tell
fx to skip every 8 pixels for you.
I would discuss your problem with Anthony. I am told that you can
compile IM into a 32-bit version Q32 called HDRI (I think) and that
this might work to solve your problem. Discuss this with Anthony.
Fred Weinhaus
____________________
I've done some testing in the meanwhile, trying to perform this
operation by the use of 16-bit images. After downloading and installing
the current Windows 16-bit executable (6.3.5-10 Q16), I stripped the
operation down to:
convert -depth 16 -size 64x64 xc:grey50 grey.tif
identify -verbose grey.tif >log.txt
convert grey.tif -fx "1/256" x.tif
identify -verbose x.tif >>log.txt
convert x.tif x.tif -compose multiply -composite x2.tif
identify -verbose x2.tif >>log.txt
and got strange results (see below).
Anyone who can throw some light onto this?
Wolfgang Hugemann
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users