如何在python中绘制RGB图像的3D直方图

时间:2013-03-20 12:58:38

标签: python matplotlib histogram

我想绘制RGB图像的3D直方图。 以下是我的代码:

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
from scipy.misc import imread
import pylab

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
img1 = imread('image.jpg')
img_reshaped = img1.reshape(img1.shape[0] * img1.shape[1], img1.shape[2])

hist, edges = np.histogramdd(img_reshaped, bins=(100, 100, 100))

请告诉我如何绘制我获得的hist直方图。

1 个答案:

答案 0 :(得分:0)

您是否看过matplotlib图库中的3d直方图示例?

请参阅:http://matplotlib.org/examples/mplot3d/hist3d_demo.html