I want to use ImageJ to do some processing of several thousand images.
Is there a way to take any general imageJ plugin and apply it to hundreds of images automatically?
For example, say I want to take my thousand images and apply a polar transformation to each---
A polar transformation plugin for ImageJ can be found here:
http://rsbweb.nih.gov/ij/plugins/polar-transformer.html
Great! Let's use it. From:
http://albert.rierol.net/imagej_programming_tutorials.html#How%20to%20automate%20an%20ImageJ%20dialog
I find that I can apply a plugin using the following:
(defn x-polar
[imageP]
(let [thread (Thread/currentThread)
options ""]
(.setName thread "Run$_polar-transform")
(Macro/setOptions thread options)
(IJ/runPlugIn imageP "Polar_Transformer" "")))
开发者_JAVA技巧
This is good because it suppresses the dialog which would otherwise pop up for every image. But running this always brings up a window containing the transformed image, when what I want is to simply return the transformed image.
The stupidest way to do what I want is to just close the window that comes up and return the image which it was displaying.
Does what I want but is absolutely retarded:
(defn x-polar
[imageP]
(let [thread (Thread/currentThread)
options ""]
(.setName thread "Run$_polar-transform")
(Macro/setOptions thread options)
(IJ/runPlugIn imageP "Polar_Transformer" "")
(let [return-image (IJ/getImage)]
(.hide return-image)
return-image)))
I'm obviously missing something about how to use imageJ plugins in a programming context. Does anyone know the right way to do this?
Thanks, --Robert McIntyre
Unfortunately, it's very common for ImageJ plugins to be written without programmatic use in mind, and there's not really an elegant way of getting around that without changing the code of the plugin. (You've already discovered that there are unsatisfactory ways around it :)) So, in your position I would just change the code in Polar_Transformer.java
in the following way:
http://gist.github.com/452826
... which is vaguely along the lines suggested in the Fiji PlugIn Design Guidelines, while still trying to just make minimal changes to the original code. Then you can just create the PlugIn object and call exec(...)
on it supplying the options you want. (I haven't really tested that patch, but you get the idea.)
I hope that's of some help - I see that your question was some time ago, though, so I guess you may have found some other workaround in the mean time.
精彩评论