#### How to plot 3d graphics with the values of each pixel of the image?

``````import cv2
imlab=cv2.cvtColor(imbgr,cv2.COLOR_BGR2LAB)
cv2.imwrite('lab.jpg',imlab)
``````

1 个回复

``````import cv2
import numpy as np

import matplotlib.image as mpimg

import matplotlib.pyplot as plt

# for the surface map
from mpl_toolkits.mplot3d import Axes3D

imrgb = cv2.cvtColor(imbgr, cv2.COLOR_BGR2RGB)

imlab=cv2.cvtColor(imbgr,cv2.COLOR_BGR2LAB)

# Show the original image and individual color channels
plt.figure(0)
plt.subplot(2,2,1)

plt.imshow( imrgb )

plt.subplot(2,2,2)
plt.imshow(imbgr[:,:,0], cmap='Blues')

plt.subplot(2,2,3)
plt.imshow(imbgr[:,:,1], cmap='Greens')

plt.subplot(2,2,4)
plt.imshow(imbgr[:,:,2], cmap='Reds')

plt.show()

# show the LAB space iamge
plt.figure(1)
plt.subplot(2,2,1)

plt.imshow( imrgb )

plt.subplot(2,2,2)
plt.imshow(imlab[:,:,0], cmap='Greys')

plt.subplot(2,2,3)
plt.imshow(imbgr[:,:,1], cmap='cool')

plt.subplot(2,2,4)
plt.imshow(imbgr[:,:,2], cmap='cool')

plt.show()

# contour map
plt.figure(2)

y = range( imlab.shape[0] )
x = range( imlab.shape[1] )
X, Y = np.meshgrid(x, y)

plt.contour( X, Y, imlab[:,:,0], 50 )

plt.show()

# surface map
plt.figure(3)

ax = plt.axes(projection='3d')

y = range( imlab.shape[0] )
x = range( imlab.shape[1] )
X, Y = np.meshgrid(x, y)

ax.plot_surface( X, Y, imlab[:,:,0] )

plt.show()
``````

1 如何用像素绘制3D对象？

2 使用Matlab通过在每个像素处绘制线条将2D图像转换为3D

2018-10-16 01:08:33 0 78   3d
3 图形引擎如何确定如何放置像素以制作3d图像？

2013-05-23 13:11:00 1 97   3d/ pixels
5 如何在3D图形matplotlib中绘制图像

2019-03-08 16:27:11 0 198   3d
6 绘制 3d 图形的问题

7 如何使用图像中每个像素的颜色绘制图形？

2018-10-13 00:08:37 1 495   graph
8 如何绘制3D图像？

9 像素化图形和3D表示

2012-08-20 11:12:30 1 112   c#/ opengl
10 如何用Java制作3D图形？ [关闭]

2015-12-30 07:29:46 3 3091   java/ awt