NIH LISTSERV
NIH LISTSERV
IMAGEJ archives -- May 2002 (#150)

Go to: Previous Message | Next Message
Previous in Topic | Next in Topic
Previous by Same Author | Next by Same Author
Previous Page (May 2002) | Back to Main IMAGEJ Page


Options: Reply | Post a New Message | Join or Leave IMAGEJ, or Change Options | Search
View: Chronologically | Most Recent First | Wrap Text (Proportional Font) | Don't Wrap Text (Non-proportional Font)
*

Content-type: text/plain; charset=iso-8859-1
References: <[log in to unmask]>
Message-ID:  <007001c202ac$9692f8c0$05a8a8c0@lazarus>
Date:         Thu, 23 May 2002 15:53:00 -0700
Reply-To:     ImageJ Interest Group <[log in to unmask]>
Sender:       ImageJ Interest Group <[log in to unmask]>
From:         cjtaylor <[log in to unmask]>
Organization: nbresearch.com
Subject:      ImageJ: Is there a clean way to write a command line tool that
              uses ImageJ

Hi. I'm using ImageJ both on the Windows side and on a Linux box. On the Linux box, I'm trying create a set of command-line tools that I can call and use for batch processing of images from shell scripts (on 3D Analyze format images using Guy William's Plugins). The following class example appears to do the job: import ij.*; import ij.measure.*; import java.io.*; public class CommandLineMaskImage{ public static void main(String argv[]){ if (argv.length!=3){ System.out.println("MaskImage usage:"+ "MaskImage [mask image] [input image] [outputimage]"); return; } else{ ImageJ mainFrame=null; if (IJ.getInstance()==null){ mainFrame= new ImageJ(); } IJ.run("Analyze Reader", "path='"+argv[0]+".hdr'"); IJ.run("Rename...", "title=mask"); IJ.run("Analyze Reader", "path='"+argv[1]+".hdr'"); IJ.run("Rename...", "title=image"); ImagePlus imp=WindowManager.getCurrentImage(); Calibration c = imp.getCalibration(); IJ.run("Image Calculator...", "image1=mask operation=AND image2=mask create"); IJ.selectWindow("Result"); ImagePlus rimp =WindowManager.getCurrentImage(); rimp.setCalibration(c); IJ.run("Analyze Writer", "path='"+argv[2]+".hdr'"); mainFrame.quit(); } } } It can be executed from the command line with something like: java CommandLineMaskImage /home/cjtaylor/javaf/maskimage /home/cjtaylor/javaf/actualimage /home/cjtaylor/javaf/outputImage Two Questions: 1) When I run this, I need to have the plugins folder directly underneath the folder containing CommandLineMaskImage.class. Is there someway to set this folder by calling an ImageJ instance or through an IJ static method when not running the standard ImageJ GUI? 2) Since each of the IJ.run() commands are supposed to run on separate threads, I would have throught that this code might not work properly due to synchronization issues, but it appears to be working. Is this simply a machine timing fluke and, in truth, I'm playing with fire or is there something that guarantees that each command waits for the previous command to complete? Thanks for any feedback, CJ




Back to: Top of message | Previous page | Main IMAGEJ page

NIH LISTSERV Home Page

CIT
Center for Information Technology
National Institutes of Health
Bethesda, Maryland 20892
301 594 6248 (v) 301 496 8294 (TDD)
Comments and Assistance
Accessibility wheelchair icon