In an ImageJ plugin, what is the best way to access an already-open image?
At first I tried this:
private ImagePlus imgp = null;
This didn’t work at all. I would always get two popup windows saying “A ImagePlus is required but none exist”, even though I already had an image open.
So next I looked through the examples, and it looks like they all use this:
private Dataset currentData;
final Img<T> image = (Img<T>)currentData.getImgPlus();
This code does actually work, and I can get an ImgPlus out of it. However, ImgPlus’s javadoc says
NOTE: This class is slated for redesign in spring 2016. Use at your own risk! If you need future stability, use ImgLib2 and/or ImageJ 1.x classes.
I’m pretty sure that this refers to ImagePlus, and maybe some other class I’m not aware of.
Also, I’m suspicious of the fact that you need to use a generic
Img instead of just an
ImgPlus. (I tried, and you really do need to use
Img<T>.) This still doesn’t seem like the best (right?) way to access an open image.