Fast display of an array as an image

Ok, I figured that one out - I need a display(imgplot) if I’m not in a REPL. So here’s a complete working example.


println("loading packages (this may take a while)")

using GLMakie, Images

println("opening a plot window (this may take a while)")

img = Observable(rand(RGB{N0f8}, 512, 512));

imgplot = image(@lift(rotr90($img)),
                axis = (aspect=DataAspect(),),
                figure = (figure_padding=0, resolution=size(img[])))

hidedecorations!(imgplot.axis)

display(imgplot)

println("running...")

nframes = 0
tmax = 10
t0 = time();
while time() - t0 < tmax
    global nframes
    img[] = rand(RGB{N0f8}, 512, 512)
    sleep(0)
    nframes += 1
end

println("achived a fps of $(nframes/tmax)")

I’m getting a theoretical framerate of 178, but it looks a bit jerky, so I’m guessing it doesn’t actually display every frame. The time-to-first-plot is really really long unfortunately :frowning:

2 Likes