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

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)
*

Delivered-To: [log in to unmask]@fixme
References: <[log in to unmask]>
Content-Type: multipart/mixed;
Message-ID:  <[log in to unmask]>
Date:         Thu, 16 May 2002 17:37:54 -0700
Reply-To:     [log in to unmask]
Sender:       ImageJ Interest Group <[log in to unmask]>
From:         Bob Dougherty <[log in to unmask]>
Organization: OptiNav, Inc.
Subject:      Re: Threshold...

Rachel, Here is another (lower level) take on it. The key step is ByteProcessor bp = (ByteProcessor)ips; bp.applyLut(); which applies the lookup table from setThreshold to the image processor ips for each slice. After thresholding the slices of the stack, the plugin applies the ParticleAnalyzer to them. It runs, but since I don't have a clue what particle analysis means, it may not be correct. Bob Kurt De Vos wrote: > Ip.run(String)is not a valid method. IJ.run(String)on the other hand is. > IJ.run("Threshold","Stack"); should do the trick > > Kurt > > > -----Original Message----- > > From: ImageJ Interest Group [mailto:[log in to unmask]] On > > Behalf Of Rachel Bearon > > Sent: May 16, 2002 14:34 > > To: [log in to unmask] > > Subject: Re: Threshold... > > > > > > On Wed, 15 May 2002 07:25:39 -0700, Bob Dougherty > > <[log in to unmask]> > > wrote: > > > > >Gary, > > > > > >It looks like > > > > > >ip.setThreshold(double minThreshold, double maxThreshold, int > > >lutUpdate) > > > > > >where ip is your image's processor and lutUpdate is > > >ImageProcessor.BLACK_AND_WHITE_LUT > > > > > > > I'm a newbie to ImageJ, and found this advice very helpful. > > However, when I tried to run ParticleAnalyser on the stack, I > > got the error that the stack needed to be thresholded. In the > > previous mail from Wayne on this thread, he suggested running > > > > >IJ.setThreshold(minThreshold, maxThreshold); IJ.run("Threshold"); > > > > on version 1.28e or later. However I could only download > > version 1.28d from the ImageJ website. To try and fudge a > > solution, I tried putting the following in my plugin: > > ip.setThreshold(minThreshold, maxThreshold, lutUpdate ); > > ip.run("Threshold"); > > > > but got the following error > > Method run(java.lang.String) not found in class > > ij.process.ImageProcessor. > > > > Thanks, Rachel > > -- Robert Dougherty President, OptiNav, Inc. (425) 467-1118 [log in to unmask] http://www.optinav.com


import ij.*; import ij.plugin.filter.PlugInFilter; import ij.process.*; import ij.plugin.filter.ParticleAnalyzer; import ij.gui.*; import java.awt.*; import java.util.*; /** This plugin applies a B&W threshold and performs particle analysis. */ public class Try_Thresh implements PlugInFilter { ImagePlus imp; double minThreshold = 0; double maxThreshold = 255; boolean canceled; public int setup(String arg, ImagePlus imp) { this.imp = imp; return DOES_8G + DOES_8C; } public void run(ImageProcessor ip) { getThresh(); if (canceled) return; int numSlices = imp.getStackSize(); ImageStack stack = imp.getStack(); //Threshold the stack for (int i = 0; i < numSlices; i++){ ImageProcessor ips = stack.getProcessor(i+1); ips.setThreshold((int) minThreshold, (int) maxThreshold, ImageProcessor.BLACK_AND_WHITE_LUT); ByteProcessor bp = (ByteProcessor)ips; bp.applyLut(); } imp.setStack(null,stack);//Something you need to do after changing a stack. imp.updateAndDraw(); //Perform particle analysis, whatever that is. ParticleAnalyzer pa = new ParticleAnalyzer(); pa.showDialog(); for (int i = 0; i < numSlices; i++){ imp.setSlice(i+1); pa.analyze(imp); //I think the above 2 lines could also have been // ImageProcessor ips = stack.getProcessor(i+1); // pa.run(ips); // and this would have done the processing behind the scenes // and would require // imp.setStack(null,stack);//Something you need to do after changing a stack. // and // imp.updateAndDraw(); // later. } } private void getThresh() { GenericDialog gd = new GenericDialog("Enter Thresholds", IJ.getInstance()); gd.addNumericField("minThreshold", minThreshold, 0); gd.addNumericField("maxThreshold", maxThreshold, 0); gd.showDialog(); if (gd.wasCanceled()) { canceled = true; return; } minThreshold = gd.getNextNumber(); maxThreshold = gd.getNextNumber(); } }



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