Documentation http://www.imagemagick.org/Usage/compos ... s_subtract states "This operator [ModulusSubtract] is not recommended for use in any situation, as 'ModulusAdd' with a Negated Image will provide the same result." But this isn't quite true because black is zero and white is 65535 (in Q16), and 65535 is treated as -1 in modulus arithmetic. -1 is close, but not equal, to zero.
(In addition, the link is broken, and should be to http://www.imagemagick.org/Usage/color_mods/#negate .)
The following commands show the difference:
convert xc:#000100020003 m.png
convert m.png txt:
#000100020003
convert xc:black m.png -compose ModulusSubtract -composite txt:
#000100020003
convert ( xc:black -negate ) m.png -compose ModulusAdd -composite txt:
#000000010002
We can cure the problem by adding 1:
convert ( xc:black -negate ) m.png -compose ModulusAdd -composite -evaluate AddModulus 1 txt:
#000100020003
Tested under IM v6.8.7-1 on Windows 7.
Modulus Subtract and Add
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Modulus Subtract and Add
snibgo's IM pages: im.snibgo.com
Re: Modulus Subtract and Add
We can reproduce the problem you posted and have a patch in ImageMagick 6.8.7-4 Beta available by sometime tomorrow. Thanks.