Short Description

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

Versions

  • Version 1 • Released on: 2013-03-11 13:56:09
    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)
    importClass(Packages.plugins.tprovoost.bestthreshold.BestThreshold)
    
    importPackage(Packages.plugins.adufour.thresholder)
    
    /* 
    Get the focused Sequence. This is a shortcut for:
    	Icy.getMainInterface().getFocusedSequence()
    */
    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")
    	gui.addSequence(result)	
    }
    
    

Leave a Review