![]() | ![]() |
![]() |
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 | | ![]()
Reply
| Post a New Message |
Join or Leave IMAGEJ, or Change Options
|
Search | ![]()
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]> <007001c202ac$9692f8c0$05a8a8c0@lazarus> Message-ID: <00f701c202b4$6829bd90$05a8a8c0@lazarus> Date: Thu, 23 May 2002 16:48:58 -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: command line tool that uses ImageJ questionSorry - goofed up making the condenced version of the code: IJ.run("Image Calculator...", "image1=mask operation=AND image2=mask create"); should be IJ.run("Image Calculator...", "image1=mask operation=AND image2=mask create stack"); CJ ----- Original Message ----- From: "cjtaylor" <[log in to unmask]> To: <[log in to unmask]> Sent: Thursday, May 23, 2002 3:53 PM 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
![]() |
![]() Center for Information Technology National Institutes of Health Bethesda, Maryland 20892 301 594 6248 (v) 301 496 8294 (TDD) Comments and Assistance Accessibility ![]() |