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

Auto Threshold

by tprovoost / Thomas Provoost

Auto Thresholder using KMeans method. Based on Thresholder 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.
*/
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)	
}

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



Icy script publication Id : A4W1C3