Script

count number of pixels of zero intensity in ROIs

Publication ID: ICY-W8K2N5

Short Description

This script takes the current active sequence and loop over its region of interest. For each ROI, it displays the number of pixels contained in the ROI, and the number of pixels having an intensity of zero.

Versions

  • Version 2 • Released on: 2014-09-10 10:01:34
    Download
    Description:

    Script fixed ( ==0 instead of != 0 )
    Percentage added

    importClass(Packages.icy.sequence.SequenceDataIterator)
    importClass(Packages.icy.roi.ROIUtil)
    
    seq = getSequence()
    
    roiList = seq.getROI2Ds()
    
    for ( i = 0 ; i < roiList.size() ; i++ )
    {
    	
    	roi = roiList.get( i )
    	println("ROI " + roi.getName() +":" )
    
    	totalPixel = roi.getArea()
    	println("Total number of pixel: " + totalPixel )
    
    	iterator = new SequenceDataIterator( seq, roi)
    	nbPixelZeroValue = 0
    	while ( !iterator.done() )
    	{	
    		value = iterator.get()
    		if ( value == 0 ) nbPixelZeroValue++
    
    		iterator.next()
    	}
    	
    	println( "number of pixels having value 0:" + nbPixelZeroValue )
    
    	percentOfPixelAtZero = 100.0 * nbPixelZeroValue / totalPixel
    	println( "% of pixel at 0 value: " + percentOfPixelAtZero )
    	
    }
    
    
  • Version 1 • Released on: 2014-09-08 11:12:12
    Download
    Description:

    initial version

    importClass(Packages.icy.sequence.SequenceDataIterator)
    importClass(Packages.icy.roi.ROIUtil)
    
    seq = getSequence()
    
    roiList = seq.getROI2Ds()
    
    for ( i = 0 ; i < roiList.size() ; i++ )
    {
    	roi = roiList.get( i )
    	println("ROI " + roi.getName() +":" )
    
    	println("Total number of pixel: " + roi.getArea() )
    
    	iterator = new SequenceDataIterator( seq, roi)
    	nbPixelZeroValue = 0
    	while ( !iterator.done() )
    	{	
    		value = iterator.get()
    		if ( value != 0 ) nbPixelZeroValue++
    
    		iterator.next()
    	}
    	
    	println( "number of pixels having value 0:" + nbPixelZeroValue )
    	
    }
    
    

Leave a Review