Re: Compare -FUZZ <- how it is calculated
Posted: 2017-11-13T21:38:34-07:00
Internally IM uses its compile time quaility setting. 8 bit images are stored at that quality and then saves at the current image 'depth' whcih is usualy the image input depth. Also HDRI versions of IM store values a floating poitn numbers in memory but use Q16 as a base for those numbers.
EG typically when reading and writing and image in Q16 IM
8bit image file --> 16bit memory --> 8bit image file
metric PAE is Peak Absolute Error -- Which is the largest 'error' distance between individual values, and not the diagonal colorspace distance.
In other words it is a Chebyshev Distance also known as a King's or Queen's distance in the distance a king or queen would move on a chess board.
As such for a black pixel vs a white pixel this is the 0 to 2^Q where Q is typically 16 or 65535. in Q8 that would be 255
NOTE I used IM itself to specify the image color to avoid the 'input' confusion.
-compare FUZZ will be using the colorspace distance (diagonal) also known as Euclidean distance (or a as the crow flies, distance)
As such the distance should be sqrt(3)*2^Q or roughly 113511 (for the -fuzz threshold).
However "compare" seems to do things a little differently to the -fuzz calculation. Basically it calculated in floating point, and then multiplies this 'normalised' value by Q^16 so it can be stored into the resulting image, in memory, to ensure it does not overflow the image bounds.
Best idea when using compare is to ignore the actual number and only use the floating point value (in parenthesis). So white to black is a floating (normalized) value of 1, same as for PAE.
But you can see the difference between the two metrics clearly if you compare colors like Black to Cyan (cyan is #00FFFF or 0,255,255)
PAE will still get a maximum value distance (255 at Q8 or 65535 at Q16, or 1.0), but FUZZ will have a normalized value sqrt(2) / sqrt(3) or .816
Note that this is all "in memory", when saving to a image that value will be converted to the appropriate "depth" for that image be it depth 8 (GIF,JPEG), 16 (PNG), or floating point (PFM - PbmPlus floating point image).
Compare does not provide a Manhatten Distance (Taxicab) Metric (simple addition of the difference of all color channels), but
you can generate such a difference images very easily...
http://www.imagemagick.org/Usage/compare/#difference
EG typically when reading and writing and image in Q16 IM
8bit image file --> 16bit memory --> 8bit image file
metric PAE is Peak Absolute Error -- Which is the largest 'error' distance between individual values, and not the diagonal colorspace distance.
In other words it is a Chebyshev Distance also known as a King's or Queen's distance in the distance a king or queen would move on a chess board.
As such for a black pixel vs a white pixel this is the 0 to 2^Q where Q is typically 16 or 65535. in Q8 that would be 255
Code: Select all
[b]compare xc:black xc:white -metric PAE null:[/b]
65535 (1)
-compare FUZZ will be using the colorspace distance (diagonal) also known as Euclidean distance (or a as the crow flies, distance)
As such the distance should be sqrt(3)*2^Q or roughly 113511 (for the -fuzz threshold).
However "compare" seems to do things a little differently to the -fuzz calculation. Basically it calculated in floating point, and then multiplies this 'normalised' value by Q^16 so it can be stored into the resulting image, in memory, to ensure it does not overflow the image bounds.
Best idea when using compare is to ignore the actual number and only use the floating point value (in parenthesis). So white to black is a floating (normalized) value of 1, same as for PAE.
Code: Select all
compare xc:white xc:black -metric FUZZ null:
65535 (1)
PAE will still get a maximum value distance (255 at Q8 or 65535 at Q16, or 1.0), but FUZZ will have a normalized value sqrt(2) / sqrt(3) or .816
Code: Select all
[b]compare xc:black xc:cyan -metric PAE null:[/b]
65535 (1)
[b]compare xc:black xc:cyan -metric FUZZ null:[/b]
53509.1 (0.816497)
Compare does not provide a Manhatten Distance (Taxicab) Metric (simple addition of the difference of all color channels), but
you can generate such a difference images very easily...
http://www.imagemagick.org/Usage/compare/#difference