Posted by
Rasband, Wayne (NIH/NIMH) [E] on
Jul 24, 2015; 1:27am
URL: http://imagej.273.s1.nabble.com/questions-about-ImageJ-javascript-scripts-language-tp5013709p5013727.html
On Jul 22, 2015, at 10:41 PM, Xiuxia Zhang <
[hidden email]> wrote:
>
> I am a PhD. candidate of Institute of Computing Technology, Chinese
> Academy of Sciences.
> My research interest is image processing.
> I am a user of ImageJ. Recently I am writing ImageJ scripts. Mostly I
> refer this page
>
http://imagej.nih.gov/ij/developer/macro/functions.html> I also use Plugins->Macros->Record to generate the scripts automaticly.
>
> However I find some commands that not written in the documents I listed
> above.
> I have a need to read lots of text Image automaticly and save as Tiff
> image.
>
> I need the comands Such as "File-->import-->textImage".
> The macros generated is not correct for javascript, beanshell or java.
> It's only correct as Fiji's Macro language. I can not use Js, java or
> beanshell language.
This bug is fixed in the latest ImageJ daily build (1.50b1). The recorder now generates something like
imp = IJ.openImage("/Users/wayne/boats.txt");
IJ.saveAs(imp, "Tiff", "/Users/wayne/boats.tif");
imp.close();
when you open a text image, save it in TIFF format and close it. The Process>Batch>Convert command now works with text images so you can use it to convert a folder of text images into another format.
-wayne
> I am using ImageJ 1.49P.
> I just wonder what should I do if I can not macros I needed of Javascript
> in the documents.
>
>
> Here is the code snips of each language. I also imported necessary
> packages before these codes.
> Macro
> IJ.run("Text Image... ",
> "open=/home/xiuxia/home2/result/predict_14img.txt");
> IJ.run("Conversions...", " ");
> IJ.saveAs(imp, "Tiff", "/home/xiuxia/home2/result/predict_14img0000.tif");
> imp.close();
>
>
> javascript:
> imp = IJ.getImage();
> IJ.run("Text Image... ",
> "open=/home/xiuxia/home2/result/predict_14img.txt");
> IJ.run("Conversions...", " ");
> IJ.saveAs(imp, "Tiff", "/home/xiuxia/home2/result/predict_14img0000.tif");
> imp.close();
>
> Beanshell
> imp = IJ.getImage();
> IJ.run("Text Image... ",
> "open=/home/xiuxia/home2/result/predict_14img.txt");
> IJ.run("Conversions...", " ");
> IJ.saveAs(imp, "Tiff", "/home/xiuxia/home2/result/predict_14img0000.tif");
> imp.close();
>
> java
> *import ij.*;*
> *import ij.process.*;*
> *import ij.gui.*;*
> *import java.awt.*;*
> *import ij.plugin.*;*
> *import ij.plugin.frame.*;*
>
> *public class My_Plugin implements PlugIn {*
>
> * public void run(String arg) {*
> * ImagePlus imp = IJ.getImage();*
> * IJ.run("Text Image... ",
> "open=/home/xiuxia/home2/result/predict_14img.txt");*
> * IJ.run("Conversions...", " ");*
> * IJ.saveAs(imp, "Tiff",
> "/home/xiuxia/home2/result/predict_14img0000.tif");*
> * imp.close();*
> * }*
>
> *}*
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html