# Image quantization for grayscale images with alpha channel

I am looking for algorithm that quantize grayscale image that contains alpha to 4-bits (16 colors). I quite like the effect that is used in IrfanView to decrease color depth, however, I dont know the exact algorithm plus the alpha channel is lost.

Currently I am using Wu's Color Quantizer that works with RGB images. I map my grayscale as R = grey, G = grey, B = alpha. However, this approach is not always correct.

I would also like to be able to keep certain grayscale value, that I specify. Currently, I do that manually by increasing number of pixels of this value.