I wanted to see the output of the surface plot and wanted to be able to move it around, so that I don’t have to set a fixed elevation and azimuth. Though I eventually was able to get the output but it’s super slow, not able to move it that seamlessly and thinking that it’s the issue with my machine’s processing power, I thought of running same thing on Google colab… doesn’t seem to be working there. Any idea folks what’s the issue?
Code is following(you can use any image having a face):
import cv2 from mpl_toolkits.mplot3d import Axes3D from matplotlib import pyplot as plt import numpy as np %matplotlib notebook img = cv2.imread('74113_v9_bb.jpg', 0) x, y = np.mgrid[0:img.shape, 0:img.shape] fig = plt.figure(figsize=(11, 11)) ax = fig.gca(projection='3d') ax.plot_surface(x, y, img, rstride=1, cstride=1, cmap=plt.cm.gray, linewidth=1) ax.view_init(90, 30) plt.show()
All I am trying to do is to create a pixel intensity of a grayscale image as a surface plot.
Output image(not the interactive plot):
So I got the result but it’s super slow. Can anyone explain why?