Converting a PyCall numpy ×3 Array{UInt8, 3} to RGB

The precise steps may depend on your data (e.g., RGB vs BGR; Julia supports both), but this demo may get you started:

julia> using PyCall, ImageCore, ImageView

julia> si = pyimport("skimage.data")
PyObject <module 'skimage.data' from '/usr/lib/python3/dist-packages/skimage/data/__init__.py'>

julia> dat = pycall(si.rocket, PyArray);

julia> img = reinterpretc(RGB{N0f8}, PermutedDimsArray(dat, (3, 1, 2)));

julia> imshow(img)

ImageCore has an extensive set of composable no-copy operations for reinterpreting the meaning of raw data; with them, you should be able to do anything you want. Please see the docs at ImageCore.jl · ImageCore

5 Likes