Posterization filter explained?

Awesome! I am also going to post my code on this thread!

I also found a related topic: