Search code examples
bitmapgimp

Gradient banding in bitmap image


There is a png for a vehicle speedometer, it's a blue-black gradient it looks nice in png format but when i convert to 16bit a1r5g5b5 BMP image (in GIMP) the gradient starts banding. Can i avoid somehow? I know this is not the best place for this, but maybe there is a computer master here who knows.

Sorry for my bad english.

Smooth png

Unsmooth, banding bmp


Solution

  • In your A1R5G5B5 bitmap, you only have 5 bits per channel, and so 32 values over the full range (in other words, a step of 1 over 5 bits is like a step of 8 in a regular 8bit/channel image).

    So, your initial image a small range of colors (still, 592 different RGB values, according to Color > Info > Color cube analysis):

    enter image description here

    When you reduce this to 5-bit/channel: your red channel goes from 35 to 4,so the 31 values are now 4 values, and likewise your green channel has 6 values and your blue as 9-10. The end result has very few colors (27) so not even all combinations are used...

    enter image description here

    A solution here is to "dither": your pixels assume the rather quantized colors but are spread a bit randomly. This can be done with Colors > Dither and using 32 values per channel:

    enter image description here

    The histogram is very similar to the banded picture one and you still have very few colors (76 (*)) but since the pixels are arranged randomly this is much less visible (this is a reload of the dithered image saved as an A1R5G5B5 bitmap):

    enter image description here

    (*) There are more colors because the dithering can use colors that aren't in your gradient, but which, combined with neighboring pixels with colors that are or are not in the gradient, generate a result which is visually similar to the gradient.