0
点赞
收藏
分享

微信扫一扫

灰度图像绘制3D图像

陌岛 2022-04-05 阅读 111
python
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import cv2

if __name__ == "__main__":
    img_path = r"./afterdata/824994join292.png"
    img_gray = cv2.imread(img_path, 0)

    # img_gray = cv2.resize(img_bgr, (224, 224))
    print(img_gray.shape)
    Y = np.arange(0, np.shape(img_gray)[0], 1)
    X = np.arange(0, np.shape(img_gray)[1], 1)
    print(X.shape)
    X, Y = np.meshgrid(X, Y)
    print(X.shape,Y.shape)
    fig = plt.figure()
    ax = plt.axes(projection="3d")
    ax.plot_surface(X, Y, img_gray, cmap='gist_rainbow')  #  cmap='hot'
    ax.invert_zaxis()
    plt.show()
举报

相关推荐

0 条评论