![]() | ![]() |
![]() |
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="us-ascii" Message-ID: <[log in to unmask]> Date: Mon, 27 May 2002 21:43:15 -0400 Reply-To: ImageJ Interest Group <[log in to unmask]> Sender: ImageJ Interest Group <[log in to unmask]> From: Wayne Rasband <[log in to unmask]> Subject: Re: Automation of image import and length determination In-Reply-To: <[log in to unmask]>At 03:00 PM 5/27/02 -0400, you wrote: >Hello, > >My current project involves capturing an image every few seconds and saving >each image as a separate file in a specified folder. I want ImageJ to >import each image file as soon as it appears in the folder (for further >real-time processing). Is there a way to do this? Here is a plugin that opens and processes captured images as they appear in a folder. The images are expected to have names in the form frame000.tif, frame001.tif, etc. The path, name, number of digits and suffix can be changed by editing the plugin. -wayne /************* Sequence_Processor.java *************/ import ij.*; import ij.process.*; import ij.gui.*; import java.awt.*; import ij.plugin.*; import ij.io.*; public class Sequence_Processor implements PlugIn { String path = "C:\\images\\"; String name = "frame"; String suffix = ".tif"; int nDigits = 3; int maxTime = 60*1000; // 60 seconds int maxFrames = 1000; public void run(String arg) { IJ.run("Set Measurements...", "area mean min display decimal=2"); for (int i=0; i<maxFrames; i++) { ImagePlus imp = openFrame(i); if (imp!=null) processFrame(i, imp); else break; } } ImagePlus openFrame(int i) { String digits = ""+i; while (digits.length()<nDigits) digits = "0"+digits; String file = path+name+digits+suffix; IJ.showStatus("opening "+file); long start = System.currentTimeMillis(); ImagePlus imp = null; Opener opener = new Opener(); do { if (System.currentTimeMillis()>start+maxTime) { IJ.showMessage("Sequence Processor", "Unable to open\n" +file+"\n" +"after trying for "+(maxTime/1000)+" seconds."); break; } imp = opener.openImage(file); IJ.wait(100); } while (imp==null); return imp; } void processFrame(int i, ImagePlus imp) { imp.show(); IJ.run("Measure"); imp.getWindow().close(); } }
![]() |
![]() Center for Information Technology National Institutes of Health Bethesda, Maryland 20892 301 594 6248 (v) 301 496 8294 (TDD) Comments and Assistance Accessibility ![]() |