The best approach to interact with images by clicking on them and retreiving position of the pixel I clicked on

GLMakie can also do this.

This piece of code plots a red cross on the position you click in the image:

using GLMakie

img = rand(50,50)

fig, ax = image(img)

display(fig)

on(events(fig).mousebutton, priority=0) do event
    if event.button == Mouse.left
        x, y = mouseposition(ax.scene)
        scatter!(ax, [x], [y], marker='+', color=:red, markersize=30)
    end
end
3 Likes