Controlled dithering, 16-bit to 8-bit
Posted: 2017-07-26T01:56:24-07:00
Hello.
I am having trouble understanding dithering. In short: I want to be able to do whatever it is Photoshop does when switching color depth (per channel) from 16-bit to 8-bit mode. The overall aim is to batch-convert normalmaps and heightmaps to an appropriate format.
To keep it simple I'm trying to convert a linear black-to-white 4k 16-bit gradient to 256 colors. I'm expecting to see no banding when zoomed in on the output. So far my only successful attempts are with ordered dithering:
magick in.tiff -ordered-dither o8x8,256 out.tiff
Which is mostly what I want, except that I'd prefer to have no discernable pattern, which I assume is what all the other dithering methods are for.
magick in.tiff out.gif
From the documentation I got the impression that default settings already should give me the result I want. This produces a gradient with undithered 16-pixel-thick bands instead.
magick in.tiff -depth 8 out.tiff
magick in.tiff -dither FloydSteinberg -depth 8 out.tiff
Same banding.
magick in.tiff -colors 255 out.tiff
magick in.tiff -dither Riemersma -colors 255 out.tiff
magick in.tiff -dither FloydSteinberg -colors 255 out.tiff
The above dithers the way I want it to, except all the way down to 64 colors.
magick in.tiff -remap out.gif out.tiff
This again dithers to 64 colors despite out.gif containing 256 colors. Tried with a 255-color palette file as well, same result. I might be misunderstanding palettes. And in general, I feel like I'm either missing something obvious or don't understand something fundamental.
(Using IM 7.0.6-3 Q16 x64 2017-07-24 / Win7)
I am having trouble understanding dithering. In short: I want to be able to do whatever it is Photoshop does when switching color depth (per channel) from 16-bit to 8-bit mode. The overall aim is to batch-convert normalmaps and heightmaps to an appropriate format.
To keep it simple I'm trying to convert a linear black-to-white 4k 16-bit gradient to 256 colors. I'm expecting to see no banding when zoomed in on the output. So far my only successful attempts are with ordered dithering:
magick in.tiff -ordered-dither o8x8,256 out.tiff
Which is mostly what I want, except that I'd prefer to have no discernable pattern, which I assume is what all the other dithering methods are for.
magick in.tiff out.gif
From the documentation I got the impression that default settings already should give me the result I want. This produces a gradient with undithered 16-pixel-thick bands instead.
magick in.tiff -depth 8 out.tiff
magick in.tiff -dither FloydSteinberg -depth 8 out.tiff
Same banding.
magick in.tiff -colors 255 out.tiff
magick in.tiff -dither Riemersma -colors 255 out.tiff
magick in.tiff -dither FloydSteinberg -colors 255 out.tiff
The above dithers the way I want it to, except all the way down to 64 colors.
magick in.tiff -remap out.gif out.tiff
This again dithers to 64 colors despite out.gif containing 256 colors. Tried with a 255-color palette file as well, same result. I might be misunderstanding palettes. And in general, I feel like I'm either missing something obvious or don't understand something fundamental.
(Using IM 7.0.6-3 Q16 x64 2017-07-24 / Win7)