|
Bugzilla – Bug 1183 |
ij.process.AutoThresholder and fiji.threshold.Auto_Threshold return different values |
Last modified: 2015-11-06 09:54:22 CST |
| ⚠ |
NOTICE! This is a static HTML version of a legacy Fiji BugZilla bug. The Fiji project now uses GitHub Issues for issue tracking. Please file all new issues there. |
| ij.process.AutoThresholder and fiji.threshold.Auto_Threshold return different... | |
|
|
|
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
Hi, I have been developing a jython script ij which I needed to autothreshold some stacks. I have first used the ij.process.AutoThresholder using histogram I got from the following snipplet: ``` for zsliceno in range(1, stack.getSize() + 1): zslice = stack.getProcessor(zsliceno) if zsno == 1: histogram = zslice.getHistogram() else: temp = zslice.getHistogram() for i in range(0, len(histogram)): histogram[i] += temp[i] thresholder = AutoThresholder() threshold = thresholder.getThreshold("Moments", histogram) ``` calling the plugin gives a different value: ``` thresholder = Auto_Threshold() anarray = thresholder.exec(image, "Moments", False, False, True, True, False, True) ``` The image is 16-bit. These seems to be a bug in ij.process.AutoThresholder, or I am doing something terribly wrong :) Information about your version of Java: os.arch => x86_64 os.name => Mac OS X os.version => 10.11.1 java.version => 1.8.0_51 java.vendor => Oracle Corporation java.runtime.name => Java(TM) SE Runtime Environment java.runtime.version => 1.8.0_51-b16 java.vm.name => Java HotSpot(TM) 64-Bit Server VM java.vm.version => 25.51-b03 java.vm.vendor => Oracle Corporation java.vm.info => mixed mode java.awt.graphicsenv => sun.awt.CGraphicsEnvironment java.specification.name => Java Platform API Specification java.specification.version => 1.8 sun.cpu.endian => little sun.desktop => null file.separator => / The up-to-date check says: REMIND_LATER Information relevant to JAVA_HOME related problems: JAVA_HOME is set to: /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home//jre imagej.dir => /Applications/Fiji.app Information about the version of each plugin: Activated update sites: ImageJ: http://update.imagej.net/ (last check:20151026205651) Fiji: http://update.fiji.sc/ (last check:20151028163859) 3D ImageJ Suite: http://sites.imagej.net/Tboudier/ (last check:20151103085731) Files not up-to-date: 968c6425 (MODIFIED) 20151103165434 Contents/Info.plist 3af43208 (MODIFIED) 20150906115145 jars/jython-shaded-2.7.0.jar e85a2018 (LOCAL_ONLY) 20150121223046 plugins/DeconvolutionLab/DeconvolutionLab_.jar 71331805 (LOCAL_ONLY) 20100820154940 plugins/jacop_.jarThe ij.process.AutoThresholder class currently only works with 8-bit histograms. To threshold a 16-bit image, ImageJ converts the image to 8-bits, gets the threshold and then scales it to a 16-bit threshold. This JavaScript demonstrates how to get the thresholds of each image in a 16-bit stack. imp = IJ.openImage("http://imagej.nih.gov/ij/images/t1-head.zip"); stack = imp.getStack(); for (i=1; i<=stack.getSize(); i++) { ip = stack.getProcessor(i); ip.setAutoThreshold("Moments dark"); print(i+" "+ip.getMinThreshold()); } I updated the AutoThresholder JavaDocs to make it clear that it only works with 8-bit images.Here is an example that shows how to get the threshold of an entire stack: imp = IJ.openImage("http://imagej.nih.gov/ij/images/t1-head.zip"); IJ.setAutoThreshold(imp, "Default dark stack"); ip = imp.getProcessor(); print("threshold: "+ip.getMinThreshold()); I used the command recorder (Plugins>Macros>Record) to generate the first two lines of code.