Need help or advice ? Come to the Icy club ! - Every other Thursday morning from 9h30 to 12h30 - Francois Jacob Building - Main hall - Pasteur

Auto Threshold Otsu

by tprovoost / Thomas Provoost

Performs a threshold on the first channel of the image via the Otsu method, from BestThreshold plugin.

version 1 (last version):

download to use and modify in Icy. How do I use scripts ? A Problem ? ask the community.
Changelog for this version: initial version
import the different Classes needed
	- Icy is needed to use getSequence() and Icy.addSequence()
	- Package thresholder is needed to do the threshold with 
	  Thresholder and KMeans classes.


Get the focused Sequence. This is a shortcut for:
seq = getSequence()
img = getImage()

// working on first channel
channel = 0

// Check if sequence is null, as we cannot perform a threshold on 
// something that does not exist.
if (img != null) {

	data2 = BestThreshold.getHistogramBins(img, channel)

	threshold = BestThreshold.Otsu(data2)
	// performs the threshold and put the result (a sequence) inside a variable
	result = Thresholder["threshold(icy.sequence.Sequence,int,double[],boolean)"](seq, 1, [threshold], false)

	// display the result of the threshold
	result.setName(seq.getName() + "thresholded")

This script has no documentation. A Problem ? ask the community.

Icy script publication Id : C5N8I3