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

count number of pixels of zero intensity in ROIs

by fab / Fabrice de Chaumont

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.

version 2 (last version):

download to use and modify in Icy. How do I use scripts ? A Problem ? ask the community.
Changelog for this version: 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 )
	
}

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


Previous versions:


version 1:

download to use and modify in Icy.
Changelog for this version: 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 )
	
}



Icy script publication Id : W8K2N5