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

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

References: <002401c1f1e5$a229d5a0$b6010b98@MOBILENICK>
            <[log in to unmask]>
Content-Type: text/plain; charset="iso-8859-1"
Message-ID:  <00a001c1f206$dd3e7cb0$b6010b98@MOBILENICK>
Date:         Thu, 2 May 2002 14:25:17 -0400
Reply-To:     ImageJ Interest Group <[log in to unmask]>
Sender:       ImageJ Interest Group <[log in to unmask]>
From:         Nick Linnenbrügger <[log in to unmask]>
Subject:      Re: LUT used for thresholding

Thanks for your help, Bob! It works well and solves my problem ... Nick. ----- Original Message ----- From: "Bob Dougherty" <[log in to unmask]> To: <[log in to unmask]> Sent: Thursday, May 02, 2002 1:28 PM Subject: Re: LUT used for thresholding > Nick, > > Here is a brute force solution. > > Bob > > > -- > 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 java.awt.*; > import java.awt.image.*; > > /** This plugin gets the LUT of an image. */ > > public class BW_LUT_check implements PlugInFilter { > > ImagePlus imp; > > public int setup(String arg, ImagePlus imp) { > this.imp = imp; > return DOES_ALL-DOES_RGB+NO_CHANGES; > } > > public void run(ImageProcessor ip) { > LookUpTable lut = imp.createLut(); > int mapSize = 0; > java.awt.image.ColorModel cm = lut.getColorModel(); > byte[] rLUT,gLUT,bLUT; > if (cm instanceof IndexColorModel) { > IndexColorModel m = (IndexColorModel)cm; > mapSize = m.getMapSize(); > rLUT = new byte[mapSize]; > gLUT = new byte[mapSize]; > bLUT = new byte[mapSize]; > m.getReds(rLUT); > m.getGreens(gLUT); > m.getBlues(bLUT); > } else { > mapSize = 256; > rLUT = new byte[mapSize]; > gLUT = new byte[mapSize]; > bLUT = new byte[mapSize]; > for (int i = 0; i < mapSize; i++){ > rLUT[i] = (byte)i; > gLUT[i] = (byte)i; > bLUT[i] = (byte)i; > } > } > boolean couldBeBW = true; > //Try to rule out B&W LUT > //First make sure R=G=B for all entries > for (int i = 0; i < mapSize; i++){ > if((rLUT[i] != gLUT[i])|(rLUT[i] != bLUT[i])){ > couldBeBW = false; > break; > } > } > if (couldBeBW) { > //Check that all LUT entries are 255 or 0. > for (int i = 0; i < mapSize; i++){ > if(((rLUT[i]&0xff) != 255)&(rLUT[i] != 0)){ > couldBeBW = false; > break; > } > } > } > > if (couldBeBW) { > IJ.showMessage("BLACK_AND_WHITE_LUT"); > } else { > IJ.showMessage("Not BLACK_AND_WHITE_LUT"); > } > } > } >




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