Matplotlib 转换列主数组以用于PyPLot直方图
在观察到它比Python快多少之后,我正在尝试对Julia进行一些基本的图像分析 有一些很好的例子说明了如何使用图像库导入文件。图像重新解释它,然后hist将其更改为列主向量Matplotlib 转换列主数组以用于PyPLot直方图,matplotlib,julia,Matplotlib,Julia,在观察到它比Python快多少之后,我正在尝试对Julia进行一些基本的图像分析 有一些很好的例子说明了如何使用图像库导入文件。图像重新解释它,然后hist将其更改为列主向量 using Images img_gld = imread("image.jpg") img_gld_gs = convert(Image,img_gld) img_gld_gs = reinterpret(Uint8,data(img_gld_gs)) import PyPlot h = PyPlot.plt.hist(
using Images
img_gld = imread("image.jpg")
img_gld_gs = convert(Image,img_gld)
img_gld_gs = reinterpret(Uint8,data(img_gld_gs))
import PyPlot
h = PyPlot.plt.hist(vec(img_gld_gs), -1:255)
PyPlot.plt.plot(h)
最后一行错误并导致错误:
“信息:正在加载帮助数据。。。
错误:PyError(:PyObject\u调用)
ValueError('设置具有序列的数组元素',)“
如何正确地将数据传递到PyPlot并显示直方图?只需使用
PyPlot.hist
:
using Images, PyPlot
img = imread("image.jpg")
PyPlot.hist(vec(img), -1:255)
另见REP:
help> PyPlot.hist