Finding the "right levels" for quantization with anim GIFs
Posted: 2011-12-29T16:21:16-07:00
So, we're talking about a video conversion to GIF, similar to the guide here. In the last step is the color quantization process with an ordered-dither, which needs to be manually figured out. It has an example like this:
So, through trial and error, you can figure out whether 23 is enough color levels or not. However, why waste colors on stuff like blue, which has a pretty low visibility on the human visual spectrum, compared to differences in red and green? So, we can do something like o8x8,23,23,11 with exactly half of the blue channels. Okay, that gives us more room to play with and we can start to increase until we hit o8x8,26,26,13.
My big question is about the methodology. I just (semi-)randomly picked a method of dividing blue by 2 and suddenly I have better color quantization. How would I go about finding the theoretical "best" quantization? Maybe the green level should be reduced? Maybe the animation has more red than usual? Maybe the human eye can't pick up polarizations of that color as much as another color?
Of course, we're talking about something a bit more complex than going up the scale on a single level variable (like o8x8,23). However, it seems like the tools would be there to figure it out. I have a histogram from the histogram: option, but how could you programmatically go about finding the best ratio between the three levels? Running through something like -scale 1x1\! -format '%[pixel:s]' info:- can give you an average color, but I'm not sure if that's the most accurate ratio to use?
Code: Select all
convert -quiet plane.avi -ordered-dither o8x8,23 -append -format %k info:
My big question is about the methodology. I just (semi-)randomly picked a method of dividing blue by 2 and suddenly I have better color quantization. How would I go about finding the theoretical "best" quantization? Maybe the green level should be reduced? Maybe the animation has more red than usual? Maybe the human eye can't pick up polarizations of that color as much as another color?
Of course, we're talking about something a bit more complex than going up the scale on a single level variable (like o8x8,23). However, it seems like the tools would be there to figure it out. I have a histogram from the histogram: option, but how could you programmatically go about finding the best ratio between the three levels? Running through something like -scale 1x1\! -format '%[pixel:s]' info:- can give you an average color, but I'm not sure if that's the most accurate ratio to use?