Just doing a simple bump_map operation in python GIMP. But the result has color banding!
import os, glob, sys, time
from gimpfu import *
image = pdb.gimp_file_load(img_path, img_path, run_mode=RUN_NONINTERACTIVE)
gray = pdb.gimp_file_load(gray_path, gray_path, run_mode=RUN_NONINTERACTIVE)
pdb.plug_in_bump_map(image, image.active_layer, gray.active_layer,
135.0, 20.00, 30, 0, 0, 0.0, 0.0, 1, 0, 0)
pdb.file_png_save_defaults(image, image.active_layer, out_path, out_path)
If I remove the "plug_in_bump_map" operation, there is no color banding in my final result saved. If I apply a gaussian blur to the grayscale image, the color banding disappears in the final result, but leaves an undesirable blurriness, what should I do? All images are PNG.
OK, so it's banding :)
But if you look closely, the banding is already in your bump map, and is sort of unavoidable since you only have 256 levels in your PNG.
Banding occurs when there is a significant change in value between two uniform areas with a somewhat linear border between them. So the two mitigations are
The best way to fix the problem is at the source, so if openCV can compute on more that 256 levels, have it do so and export the bump map in some high-bit depth format (16-bit/channel PNG could be enough, otherwise TIFF).
Otherwise if you have to start with an 8 bit bump map:
It is also possible to replace steps 4 & 5 by a selective Gaussian blur.
Edit: tried your 16bpc:
"native" result is already much better:
It can be improved with: