Short Description

Auto Thresholder using KMeans method. Based on Thresholder plugin.

Versions

  • Version 1 • Released on: 2013-03-11 11:57:01
    Download
    Description:

    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)	
    }
    
    

Leave a Review