Example #1
0
void Preprocess::GradientAnisotropicDiffusion( double timestep, double conductance, int iterations )
{
	int size3 = myImg->GetLargestPossibleRegion().GetSize()[2];

	if(size3 == 1)
	{
		typedef itk::GradientAnisotropicDiffusionImageFilter< ImageType2D, FloatImageType2D >  FilterType;
		FilterType::Pointer filter = FilterType::New();
		filter->SetInput( this->ExtractSlice( myImg, 0) );
		filter->SetTimeStep(timestep);
		filter->SetConductanceParameter(conductance);
		filter->SetNumberOfIterations(iterations);

		try
		{
			filter->Update();
		}
		catch( itk::ExceptionObject & err )
		{
			std::cerr << "ITK FILTER ERROR: " << err << std::endl ;
			return;
		}

		ImageType2D::Pointer temp = RescaleFloatToImageType( filter->GetOutput() );
		myImg = SliceTo3D( temp );
	}
	else
	{
		typedef itk::GradientAnisotropicDiffusionImageFilter< ImageType3D, FloatImageType3D > FilterType;
		FilterType::Pointer filter = FilterType::New();
		filter->SetInput(myImg);
		filter->SetTimeStep(timestep);
		filter->SetConductanceParameter(conductance);
		filter->SetNumberOfIterations(iterations);

		try
		{
			filter->Update();
		}
		catch( itk::ExceptionObject & err )
		{
			std::cerr << "ITK FILTER ERROR: " << err << std::endl ;
			return;
		}

		myImg = RescaleFloatToImageType( filter->GetOutput() );
	}
}
Example #2
0
void Preprocess::CannyEdgeDetection(float variance, float upperThreshold, float lowerThreshold)
{
	typedef itk::CastImageFilter< ImageType3D, FloatImageType3D > CastFilterType;
	CastFilterType::Pointer cast = CastFilterType::New();
	cast->SetInput( myImg );

	typedef itk::CannyEdgeDetectionImageFilter< FloatImageType3D, FloatImageType3D > FilterType;
	FilterType::Pointer filter = FilterType::New();
	filter->SetInput( cast->GetOutput() );
	filter->SetUpperThreshold(upperThreshold);		//Threshold for detected edges = threshold
	filter->SetLowerThreshold(lowerThreshold);		//Threshold for detected edges = threshold/2
	//filter->SetThreshold(threshold);		//Lowest allowed value in the output image
	filter->SetVariance(variance);			//For Gaussian smoothing
	//filter->SetMaximumError(.01f);		//For Gaussian smoothing

	try
	{
		filter->Update();
	}
	catch( itk::ExceptionObject & err )
	{
		std::cerr << "Exception caught: " << err << std::endl;
	}

	myImg = RescaleFloatToImageType( filter->GetOutput() );
}
Example #3
0
void Preprocess::DiscreteGaussianFilter(float varX, float varY, float varZ, float maxError)
{
	typedef itk::DiscreteGaussianImageFilter<ImageType3D, FloatImageType3D> FilterType;
	FilterType::Pointer filter = FilterType::New();

	FilterType::ArrayType maxErr;
    maxErr.Fill(maxError);
    filter->SetMaximumError( maxErr );

	FilterType::ArrayType variance;
	variance[0] = varX;
	variance[1] = varY;
	variance[2] = varZ;
	filter->SetVariance(variance);

	filter->SetInput( myImg );

	try
	{
		filter->Update();
	}
	catch( itk::ExceptionObject & err )
	{
		std::cerr << "ITK FILTER ERROR: " << err << std::endl ;
		return;
	}

	myImg = RescaleFloatToImageType( filter->GetOutput() );
   
}
bool VolumeProcess::RunGaussianSmoothing(float varX, float varY, float varZ, float maxErr)
{  //by xiao liang
   typedef itk::DiscreteGaussianImageFilter< ImageType, FloatImageType3D > GaussianFilterType;
   GaussianFilterType::Pointer GaussianFilter =  GaussianFilterType::New();
   GaussianFilter->SetInput(m_outputImage);
   //GaussianFilter->SetFilterDimensionality(3);
   GaussianFilterType::ArrayType maxErrTypeValue;
   maxErrTypeValue.Fill(maxErr);
   GaussianFilter->SetMaximumError( maxErrTypeValue );

   GaussianFilterType::ArrayType variance;
   variance[0] = varX;
   variance[1] = varY;
   variance[2] = varZ;
   GaussianFilter->SetVariance(variance);
   //GaussianFilter->SetMaximumKernelWidth(maxKernalWidth);
   try
    {
		GaussianFilter->Update();
    }
   catch( itk::ExceptionObject & err )
	{
		std::cerr << "ITK FILTER ERROR: " << err << std::endl ;
		return false;
	}
	m_outputImage = RescaleFloatToImageType(GaussianFilter->GetOutput());
	if(debug)
		std::cerr << "GaussianFilter Filter Done" << std::endl;
	return true;
}
Example #5
0
void Preprocess::LaplacianOfGaussian(int sigma, int min)
{
	int size3 = myImg->GetLargestPossibleRegion().GetSize()[2];

	if(size3 == 1)
	{
		typedef itk::LaplacianRecursiveGaussianImageFilter< ImageType2D, FloatImageType2D >  FilterType;
		FilterType::Pointer laplacian = FilterType::New();
		laplacian->SetNormalizeAcrossScale( true );
		laplacian->SetSigma( sigma );
		laplacian->SetInput( this->ExtractSlice( myImg, 0) );

		try
		{
			laplacian->Update();
		}
		catch( itk::ExceptionObject & err )
		{
			std::cerr << "ITK FILTER ERROR: " << err << std::endl ;
			return;
		}

		ImageType2D::Pointer temp = RescaleFloatToImageType( laplacian->GetOutput(), min );
		myImg = SliceTo3D( temp );
	}
	else
	{
		typedef itk::LaplacianRecursiveGaussianImageFilter< ImageType3D, FloatImageType3D >  FilterType;
		FilterType::Pointer laplacian = FilterType::New();
		laplacian->SetNormalizeAcrossScale( true );
		laplacian->SetSigma( sigma );
		laplacian->SetInput( myImg );

		try
		{
			laplacian->Update();
		}
		catch( itk::ExceptionObject & err )
		{
			std::cerr << "ITK FILTER ERROR: " << err << std::endl ;
			return;
		}

		myImg = RescaleFloatToImageType( laplacian->GetOutput(), min );
	}
}
bool VolumeProcess:: RunIntensityNormalize()
{
	//Rescale weights:
    typedef itk::NormalizeImageFilter< ImageType, FloatImageType3D> NormalizeImageFilter;
	NormalizeImageFilter::Pointer Normalize = NormalizeImageFilter::New();
	Normalize->SetInput(m_outputImage);
	Normalize->Update();
	m_outputImage = RescaleFloatToImageType(Normalize->GetOutput());
	return true;

}
Example #7
0
void Preprocess::DanielssonDistanceMap(void)
{
    typedef itk::DanielssonDistanceMapImageFilter<ImageType3D, FloatImageType3D>  DT_Type;
	DT_Type::Pointer filter = DT_Type::New();
	filter->SetInput( myImg );
	try
	{
		filter->Update();
	}
	catch( itk::ExceptionObject & err )
	{
		std::cerr << "ITK FILTER ERROR: " << err << std::endl;
	}
	
	myImg = RescaleFloatToImageType( filter->GetDistanceMap() );
}
bool VolumeProcess:: RunDanielssonDistanceMap(void)
{
    typedef itk::DanielssonDistanceMapImageFilter<ImageType, FloatImageType3D>  DT_Type;
	DT_Type::Pointer DTfilter = DT_Type::New();
	DTfilter->SetInput( m_outputImage );
	//DTfilter->GetDistanceMap();
	try
	{
		DTfilter->Update();
	}
	catch( itk::ExceptionObject & err )
	{
		std::cerr << "ITK FILTER ERROR: " << err << std::endl ;
		return false;
	}
	m_outputImage = RescaleFloatToImageType(DTfilter->GetDistanceMap());
	
	if(debug)
		std::cerr << "DanielssonDistanceMap Filter Done" << std::endl;
	return true;
}