2015-07-19 31 views
2

我试图在观察它比Python快多少之后用Julia做一些基本的图像分析。转换列主阵列以在PyPLot直方图中使用

这里有很好的例子介绍如何使用图片库导入文件。图像重新解释,然后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) 

最后一行是错误的,会导致错误: “INFO:加载帮助数据... 错误:PyError:( '设置与序列中的数组元素',)(PyObject_Call) ValueError异常“

如何正确地将数据传递给PyPlot并获取直方图显示?

回答

1

只需使用PyPlot.hist

using Images, PyPlot 
img = imread("image.jpg") 
PyPlot.hist(vec(img), -1:255) 

enter image description here

另请REPL help mode

help> PyPlot.hist