예제 #1
0
float get_mean(Image::Pointer im)
{
	ConstIterator it;
	it = ConstIterator(im, im->GetLargestPossibleRegion());
	
	float mean = 0, N=0;

	try
	{
		while(!it.IsAtEnd())
		{
			if(it.Get()!=0)
			{
				mean = N/(N+1)*mean + it.Get()/(N+1);
				++N;
			}
			++it;
		}
	}
	catch( itk::ExceptionObject & err)
	{
		std::cout<<"Error calculating mean, iterator error"<<std::endl;
		std::cout<<err<<std::endl;
	}

	return mean;
}
예제 #2
0
unsigned int get_max(Image::Pointer im)
{
	ConstIterator it;
	it = ConstIterator(im, im->GetLargestPossibleRegion());
	
	unsigned int max = 0;

	try
	{
		while(!it.IsAtEnd())
		{
			if(it.Get()>max)
				max = it.Get();
			++it;
		}
	}
	catch( itk::ExceptionObject & err)
	{
		std::cout<<"Error calculating maximum, iterator error"<<std::endl;
		std::cout<<err<<std::endl;
	}

	return max;
}
예제 #3
0
unsigned int get_volume(Image::Pointer im)
{
	ConstIterator it;
	it = ConstIterator(im, im->GetLargestPossibleRegion());
	
	unsigned int volume;

	try
	{
		while(!it.IsAtEnd())
		{
			if(it.Get()!=0)
				++volume;
			++it;
		}
	}
	catch( itk::ExceptionObject & err)
	{
		std::cout<<"Error calculating volume, iterator error"<<std::endl;
		std::cout<<err<<std::endl;
	}

	return volume;
}