Reputation: 45
I'm trying to do some basic image analysis with Julia after observing how much faster it is than Python.
There are good examples out there of how to import a file in using the Images library. Images reinterprets it then hist changes it to a column-major vector.
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)
The last line is wrong and causing the error : "INFO: Loading help data... ERROR: PyError (:PyObject_Call) ValueError('setting an array element with a sequence.',)"
How do I correctly pass the data to PyPlot and get the histogram to display?
Upvotes: 2
Views: 151
Reputation: 7893
Just use PyPlot.hist
:
using Images, PyPlot
img = imread("image.jpg")
PyPlot.hist(vec(img), -1:255)
Also see the REPL help mode:
help> PyPlot.hist
Upvotes: 1