Re: Dithering works not with posterize
Posted: 2012-11-12T11:59:25-07:00
Try putting -dither xxxx before -posterize.
Use https://github.com/ImageMagick/ImageMagick/discussions instead.
https://imagemagick.com/discourse-server/
https://imagemagick.com/discourse-server/viewtopic.php?t=22261
Code: Select all
convert logo: -posterize 16 o.png
Code: Select all
convert logo: -dither Riemersma -colors 16 o.png
Argument by posterize is number of color levels per channel - so by color images it is 16 power 3 = 4096 .glennrp wrote:Evendoes not work. The result has many more than 16 colors (the input has 255 colors and the output has 164)Code: Select all
convert logo: -posterize 16 o.png
works (output has 16 colors which is probably what you wanted).Code: Select all
convert logo: -dither Riemersma -colors 16 o.png
Oh, OK. That wasn't obvious from the ImageMagick documentation; I'll fix that. It is clear in the comments in magick/quantize.c though, which also seem to indicate that dithering is always on for Posterize, but as you observed, dithering seems to have no effect.Argument by posterize is number of color levels per channel - so by color images it is 16 power 3 = 4096
For me it makes sense to always allow dithering to be used with posterization. The way I'm using posterize is to reduce an image's colorspace from 32 bits to 16 bits (RGBA8888 -> RGBA4444). This is to prepare textures in an asset pipeline for an iOS game so as to halve the memory used. I'd like to enable error dithering to make the textures look as much like the original as possible, but that doesn't seem to be possible, i.e. when using "-posterize 16 -dither Riemersma" or "-posterize 16 -dither FloydSteinberg" the dither option is ignored.magick wrote:Dithering occurs if the number of levels cubed exceed the colormap limits of ImageMagick (256 colors for Q8 or 65535 colors for Q16). For example, -posterize 7 dithers for the Q8 version of ImageMagick because 7*7*7 is 343 which exceeds the 256 color limit. Otherwise it does not make sense to dither because the number of levels can be represented by the image (e.g. -posterize 6 is 216 colors, there is no errors so dithering is meaningless).
Another way to get posterize to dither is to use unique-colors, then remap:I've managed to work round this by creating an RGBA4444 colormap (using "-channel" and "-fx" options), then using "-remap" and "-dither" together.
Code: Select all
convert in.png ^
( +clone -posterize 3 -unique-colors -write temp.mpr +delete ) ^
-remap temp.mpr ^
post.png
True. I generally create one colormap for a large number of images, and a smaller map saves a lot of time re-reading it.anthony wrote:You do not need the unique-colors in the colormap for dithering, ...
For photos and video, I've experimented with posterisation etc, with and without dithering, in various colorspaces: RGB, sRGB, CIELab, OHTA, HSL and so on. I don't consistently prefer one colorspace over another; it all depends on the image. Modifying the image very slightly can make a big difference to which colorspace I prefer.anthony wrote:PS: There has been some discussion about using srgb colormaps, converted to linrar RGB space for the disther, and then the result back to sRGB. I have no experimented with this, but it seems like a fairly good idea.
very interesting video... could use some description and maybe sub-titles defining the effect being using in each scene.snibgo wrote:Some examples on http://www.youtube.com/watch?feature=pl ... YwhjiUsVsM