Dear,
I would like to know how to run imageJ with my images for linking with an external homemade program. For example, I have an image in c:\program files\imageJ\1.tif (image file) and 1smacro.txt (macro). When I typed, "java -cp ij.jar;.RunMacro 1smacro.txt" in command line of c:\program files\imageJ, java could not found "1smacro.txt". Would you give me an example for my purpose? How can I let ImageJ know 1.tif as the input parameter? Best, S. Lee |
Hi,
On Fri, 2 Oct 2009, Lee S wrote: > I would like to know how to run imageJ with my images for linking with an > external homemade program. > > For example, I have an image in c:\program files\imageJ\1.tif (image file) > and 1smacro.txt (macro). java -cp ij.jar ij.ImageJ -macro 1smacro.txt > How can I let ImageJ know 1.tif as the input parameter? You have to specify it in the macro. You can run java -cp ij.jar ij.ImageJ 1.tif -macro 1smacro.txt too, but there is no guarantee that 1.tif has been fully loaded before the macro is evaluated. Hth, Dscho |
ImageJ Interest Group <[hidden email]> wrote on 10/02/2009 10:51:36
AM: > Hi, > > On Fri, 2 Oct 2009, Lee S wrote: > > > I would like to know how to run imageJ with my images for linking with an > > external homemade program. > > > > For example, I have an image in c:\program files\imageJ\1.tif (image file) > > and 1smacro.txt (macro). > > java -cp ij.jar ij.ImageJ -macro 1smacro.txt > > > How can I let ImageJ know 1.tif as the input parameter? > > You have to specify it in the macro. You can run > > java -cp ij.jar ij.ImageJ 1.tif -macro 1smacro.txt > > too, but there is no guarantee that 1.tif has been fully loaded before > macro is evaluated. > > Hth, > Dscho Coincidentally, I was mulling over this just this morning, and found the following from Wayne (6/2/08): > You can run a macro from the command line and pass a string argument > using the -macro or -batch command line options. As an example, here is > a macro that opens an image in the 'images' directory in the users home > directory: > > name = getArgument; > if (name=="") exit ("No argument!"); > path = getDirectory("home")+"images"+File.separator+name; > setBatchMode(true); > open(path); > print(getTitle+": "+getWidth+"x"+getHeight); > > Assume it is named 'OpenImage.txt' and is located in the macros folder. > Run the command > > java -jar ij.jar -macro OpenImage blobs.tif > > and ImageJ will launch and "blobs.tif: 256x254" is displayed in the Log > window. Note that ImageJ assumed the '.txt' extension and the > Image/macros directory. Or run > > java -jar ij.jar -batch OpenImage blobs.tif > > and the ImageJ window is not opened and the "blobs.tif: 256x254" output > is displayed in the terminal window. > > -wayne This approach allows you to specify the file on the command line, but use the macro to open it, avoiding the timing problem. Jim ---------------------------------------------- Jim Passmore Research Associate Sealed Air Corporation ---------------------------------------------- |
In reply to this post by Lee S
> I would like to know how to run imageJ with my images for
> linking with an external homemade program. > > For example, I have an image in c:\program > files\imageJ\1.tif (image file) and 1smacro.txt (macro). > When I typed, "java -cp ij.jar;.RunMacro 1smacro.txt" in > command line of c:\program files\imageJ, java could not > found "1smacro.txt". Would you give me an example for my > purpose? How can I let ImageJ know 1.tif as the input > parameter? You can pass the image name or path to the macro as an argument using java -jar <path to ij.jar> -ijpath <path to ImageJ folder> -macro 1smacro 1.tif The macro can retrieve the argument using the getArgument() function path = getArgument(); if (path=="") exit("Argument is missing"); open(path); Here is a tested example that assumes the ImageJ folder is in /Applications and that the "1smacro.txt" macro is in /Applications/ImageJ/macros: java -jar /Applications/imagej/ij.jar -ijpath /Applications/ImageJ -macro 1smacro abe.tif ImageJ assumes the ".txt" extension if it is omitted. The ImageJ command line options are described at the beginning of the source file at http://rsb.info.nih.gov/ij/source/ij/ImageJ.java -wayne |
Free forum by Nabble | Edit this page |