First of all, I'm not very well-versed in Java. In fact, I'm using JLink/Mathematica to do what I want to do.
In our lab, we are taking pictures of our experiment using cameras controlled by Mathematica. We want to convert our image display program to ImageJ. The other program is a memory hog and it's slow.
From my research, I can make this happen by either writing a plug-in, a script, or a macro. I am also under the impression that whatever I write will be installed into ImageJ and controlled by the default GUI.
My question is, can I write an external program that controls an already-running instance of ImageJ? Ideally, the sequence of events would be.
- Cameras capture images through an already-existing script.
- The image-capturing script asks ImageJ to display the captured images, together with the default GUI so that I have access to the default toolset.
- I can do some profile plot and histogram through the default GUI.
- The script that hands over the images to ImageJ is closed, but the images on ImageJ were left on.
I have successfully imported ImageJ's ij class and played with it. Here's my attempt to create a picture in ImageJ. It's in Mathematica's JLink, but it's fairly translatable to Java.
Needs["JLink`"];
InstallJava[];
AddToClassPath["C:\\Program Files\\ImageJ\\ij.jar"];
ijClass = LoadJavaClass["ij.IJ"];
imagePlusClass = LoadJavaClass["ij.ImagePlus"];
JavaNew[imagePlusClass, "My New Image",
JavaNew["ij.process.ByteProcessor", 400, 400]]@show[]
ij`IJ`log["test"];
ij`IJ`getLog[]
The image created, however, was in some kind of Java windows. The already-running imageJ doesn't interact with it at all. Furthermore, I can seem to capture the log of the already-running ImageJ using getLog[].
Again, the question is, can I use an external script that is not installed in ImageJ as plugin,script, or macro to display an image on an already-running ImageJ? Alternatively, can I use an external script to call a pre-installed macro on an already-running instance of ImageJ?