AutoThresholding - Huang: ArrayIndexOutOfBound

thresholding
imagej
fiji
segmentation
Tags: #<Tag:0x00007fb8821bb8a8> #<Tag:0x00007fb8821bb380> #<Tag:0x00007fb8821bb060> #<Tag:0x00007fb8821bab88>

#1

Just stumbled across this one:

Large images seem to overtax the Huang threshold computation.

working on the following image: https://drive.switch.ch/index.php/s/GBDViw6zOuleYGe, the macro bellow

import ij.IJ
import ij.io.Opener

opener = new Opener()
imp = opener.open('/path/to/downloaded/huang-test.tif')
IJ.run(imp, "Auto Threshold", "method=Huang white");

throws:

java.lang.ArrayIndexOutOfBoundsException: 255
	at fiji.threshold.Auto_Threshold.Huang(Auto_Threshold.java:475)
	at fiji.threshold.Auto_Threshold.exec(Auto_Threshold.java:302)
	at fiji.threshold.Auto_Threshold.run(Auto_Threshold.java:219)
	at ij.IJ.runUserPlugIn(IJ.java:217)
	at ij.IJ.runPlugIn(IJ.java:181)
	at ij.Executer.runCommand(Executer.java:137)
	at ij.Executer.run(Executer.java:63)
	at java.lang.Thread.run(Thread.java:745)

I also tested ops on the gray-scale image:

# @Img(label='img') img

#@OpService ops
#@UIService ui

bw = ops.threshold().huang(img)
ui.show(bw)

this works like a charm.

I also had a quick look at https://github.com/fiji/Auto_Threshold and called it with run() and exec(), but that worked too.
So probably there is some other code running when calling it from the macro as indicated above?


#2

The version in github is the latest one, but although the commit was pushed, it hasn’t been packed to be updated in Fiji yet. If you can compile it yourself, then note that in this latest version, the “Huang” method was reverted to the original code (which is slow with 16bit images). The version that gives you an error (yes I was able to reproduce it) has been renamed as Huang2 and left there for compatibility with old macros. It is very quick with 16 bit images, but uses a different formula (written by Johannes Schindelin) and sometimes triggers an error like this, which I have not been able to fully understand.


#3

thanks for looking into this @gabriel


#4

@FelixM can I upload your sample image to github in case somebody can investigate why the Huang2 method fails in certain circumstances? Please be aware that the image will be visible to the internet. Thank you.


#5

Hi @gabriel. sure, feel free to use the image for testing.


#6

@FelixM thank you very much,