You looking for LookUp Tables (LUT). See ImageJ wiki.
Just install ImageJ or it's Fiji distribution, open your image and select Image > Lookup Tables > Choose one nice. If your image is not really grayscale (not one-channel), program raises an exception like LUTs cannot be assigned to RGB images. If so, select Image > Type > 8-bit and apply LUT again.
Use macros or language bindings (I use Jython) for automation.