How to plot a 2D image as a 3D graph import cv2 import numpy as np from mayavi import mlab img = cv2.imread('./test1.jpg') gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) h, w = gray.shape x, y = np.mgrid[0:h:1, 0:w:1] mlab.surf(x, y, gray)