I am writing a JS script that, amongst other things, needs to draw an overlay over the current image.
The overlay will change depending on the slice of the image, so the overlay for slice 1 will be different from slice 2, 3, and so on.
I have successfully created a function that draws the overlay, but now I would like to call it every time the user changes slice. I have done this in the past in Java by creating an ImageListener but I can’t quite figure out how to do it in JS.
The ImagePlus help page mentions an
addImageListener method which sounds promising, but if I try:
var im = IJ.getImage();
im.addImageListener(function (im, event)
I get this error
TypeError: img["filename.tif" (-2), 8-bit, 800x600x1x1207x1] has no such function "addImageListener"
Any suggestion on how to handle this?