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. 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();* * }* *}* Thanks, -- * Xiuxia **Zhang* *Institute of Computing Technology Chinese Academy of Sciences* -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Xiuxia,
maybe I am wrong but I think that in your *not* imagej macro code, you are trying to getImage before opening it. So I think that you could try like that: ++++ IJ.run("Text Image... ", "open=/home/xiuxia/home2/result/predict_14img.txt"); imp = IJ.getImage(); IJ.run("Conversions...", " "); IJ.saveAs(imp, "Tiff", "/home/xiuxia/home2/result/predict_14img0000.tif"); imp.close(); +++ since the opening function is IJ.run("text image.....) and then you can get it via IJ.getImage but maybe I'm wrong... Have a nice day, Emanuele Martini
Image Analyst @Ifom-IEO research campus -MI-
|
Thanks, Emanuele. You are right. Now my code works.
Here is the working code. importClass(Packages.ij.IJ); IJ.run("Text Image... ","open=/home/xiuxia/home2/result/predict_14img.txt"); imp = IJ.getImage(); IJ.run("Conversions...", " "); IJ.saveAsTiff(imp, "/home/xiuxia/home2/result/predict_14img00xx.tif"); imp.close(); On Thu, Jul 23, 2015 at 3:36 PM, Emanuele Martini <[hidden email]> wrote: > Hi Xiuxia, > maybe I am wrong but I think that in your *not* imagej macro code, you are > trying to getImage before opening it. > > So I think that you could try like that: > ++++ > > IJ.run("Text Image... ", > "open=/home/xiuxia/home2/result/predict_14img.txt"); > > *imp = IJ.getImage();* > > IJ.run("Conversions...", " "); > IJ.saveAs(imp, "Tiff", "/home/xiuxia/home2/result/predict_14img0000.tif"); > imp.close(); > +++ > > since the opening function is IJ.run("text image.....) > and then you can get it via IJ.getImage > > but maybe I'm wrong... > > Have a nice day, > Emanuele Martini > > > > > ----- > Image Analyst @Ifom-IEO research campus -MI- > -- > View this message in context: > http://imagej.1557.x6.nabble.com/questions-about-ImageJ-javascript-scripts-language-tp5013709p5013711.html > Sent from the ImageJ mailing list archive at Nabble.com. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- * Xiuxia **Zhang* *Institute of Computing Technology Chinese Academy of Sciences* -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Xiuxia Zhang
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 |
Free forum by Nabble | Edit this page |