Apply MatplotLib Or Custom Colormap To OpenCV Image
Answer : For Python >= 2.7, cmapy packages this functionality in a convenient way. Install it with: Python 2.7: pip install cmapy Python 3.x: pip3 install cmapy Or, for Anaconda (from conda-forge): conda install -c conda-forge cmapy And use it like this: import cv2 import matplotlib.pyplot as plt import cmapy # Read image. img = cv2.imread('imgs/woman.png') # Colorize. img_colorized = cv2.applyColorMap(img, cmapy.cmap('viridis')) # Display plt.imshow(img_colorized) plt.show() Different colormaps give something like this: See all the available colormaps in action here. Disclaimer: I wrote cmapy (because I needed this functionality for another project), and internally, it does pretty much the same as the other answers. In recent versions of OpenCV (starting with 3.3), there's an overload of applyColorMap , which allows you to provide a custom colormap (either 1 or 3 channel). I've modified verified.human's code to sim...