/*
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.
*/
importClass(Packages.icy.image.IcyBufferedImage)
importPackage(Packages.plugins.adufour.thresholder)
/*
Get the focused Sequence. This is a shortcut for:
Icy.getMainInterface().getFocusedSequence()
*/
seq = getSequence()
// Check if sequence is null, as we cannot perform a threshold on
// something that does not exist.
if (seq != null) {
// computes the kmeans thresholds for automatic thresholding
kmeans = KMeans.computeKMeansThresholds(seq, 0, 2, 255)
// performs the threshold and put the result (a sequence) inside a variable
result = Thresholder.threshold(seq, 0, kmeans, false)
// display the result of the threshold
result.setName(seq.getName() + "thresholded")
gui.addSequence(result)
}