How can I do batch image processing with ImageJ in Java or clojure?
Posted
by Robert McIntyre
on Stack Overflow
See other posts from Stack Overflow
or by Robert McIntyre
Published on 2010-05-02T01:37:35Z
Indexed on
2010/05/03
11:28 UTC
Read the original article
Hit count: 393
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" "")))
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
© Stack Overflow or respective owner