Pcolormesh like replacement using Images.jl?


#1

I’m trying to visualise some 2D data using Images.jl (I’ve previously been using PyPlot and pcolormesh).

using Images, ImageView
a = [2.0 3.4 100; 34 100 2; 100 34 10]
imshow(a)

image

Works well.

But when I try to do the same in an IJulia Jupter notebook, with something like

colorview(Gray,a)

I just get a blank image.

How can I take a 2D array of arbitrary floating point numbers and visualise it consistently in both ImageView and IJulia please?

Also, is there a way to do something similar to pcolormesh and get an RGB image with a supplied color pallete, scaled between some vmin and vmax please?


#2

Rob, on Windows with Julia 0.6 this works for me
Pkg.add("ImageView)
using ImageView, Images
img=colorview(Gray,a)
imshow(img)


#3

Values must be between 0 and 1, so this works:

using Images

function matrix_to_gray(a::Matrix)
    a = Float64.(a)
    b = minimum(a)
    c = maximum(a)
    d = (a .- b) / (c -b)
    colorview(Gray, d)
end