简体   繁体   English

如何在Java或clojure中使用ImageJ进行批量图像处理?

[英]How can I do batch image processing with ImageJ in Java or clojure?

I want to use ImageJ to do some processing of several thousand images. 我想使用ImageJ来处理几千个图像。

Is there a way to take any general imageJ plugin and apply it to hundreds of images automatically? 有没有办法采取任何一般的imageJ插件并自动应用于数百个图像?

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: 可以在此处找到ImageJ的极性转换插件:

http://rsbweb.nih.gov/ij/plugins/polar-transformer.html 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 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. 我显然缺少一些关于如何在编程上下文中使用imageJ插件的东西。 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. 不幸的是,ImageJ插件在没有编程使用的情况下编写是很常见的,并且在没有更改插件代码的情况下,实际上没有一种优雅的方法可以解决这个问题。 (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: (你已经发现它周围的方法不尽如人意:))因此,在你的位置我只Polar_Transformer.java通过以下方式更改Polar_Transformer.java中的代码:

http://gist.github.com/452826 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. 然后你可以创建PlugIn对象并在其上调用exec(...) ,提供你想要的选项。 (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. 我希望有一些帮助 - 我看到你的问题是不久前的,所以我想你可能在同一时间找到了其他一些解决方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM