[Insight-users] Gradient Anisotropic Diffusion Filter with 3D Ultrasound data

firebird at medison.com firebird at medison.com
Tue Apr 26 09:01:49 EDT 2005


 Hello, everyone,

 I test Gradient Anisotropic Diffusion Filter with our 3D Ultrasound data, but there was not  any change in 3D Ultrasound data.
 What's wrong? Could you check following code, please?

 Thank you.
 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 /* pVolData : Pointer of 8bit Volume Data Buffer ( ex: size - 312 x 84 x 44 ) 
    pOutoutData : Pointer of 8bit Output Data Buffer (same size of pVolData buffer)
*/
void DiffusionFilter( unsigned char *pVolData, unsigned char *pOutputData, int xsize, int ysize, int zsize )
{
	const unsigned int volume_size = xsize * ysize * zsize;

	typedef unsigned char PixelType;

	const unsigned int Dimension = 3;
	
	typedef itk::Image< PixelType, Dimension > ImageType;

	typedef itk::ImportImageFilter< PixelType, Dimension >	ImportFilterType;

	/*-------- Set Input Data with ImportFilter --------*/
	ImportFilterType::Pointer importFilter = ImportFilterType::New();

	ImportFiterType::SizeType size;	
	size[0] = xsize;
	size[1] = ysize;
	size[2] = zsize;

	ImportFilterType::IndexType start;	
	start.Fill(0);			

	ImportFIlterType::RegionType region;
	region.SetIndex( start );
	region.SetSize( size );

	importFilter->SetRegion( region );

	double origin[ Dimension ];
	origin[0] = 0.0; origin[1] = 0.0; origin[2] = 0.0;

	importFilter->SetOrigin( origin );
	
	double spacing[ Dimension ];
	spacing[0] = 1.0; spacing[1] = 1.0; spacing[2] = 1.0;

	importFilter->SetSpacing( spacing );

	importFilter->SetImportPointer( pVolData, volume_size, false );

  	/*------------Apply Gradient Anisotropic Diffusion Filter to Input Data ---------------*/
	typedef itk::Image< PixelType, Dimension >   InputImageType;
	typedef itk::Image< PixelType, Dimension >   OutputImageType;

	typedef itk::GradientAnisotropicDiffusionImageFilter< InputImageType, OutputImageType >  FilterType;
	FilterType::Pointer filter = FilterType::New(); 	

 	filter->SetInput( importFilter->GetOutput() );

	const unsigned int numberOfIterations = 4;
	const double       timeStep = 0.125;
	const double       conductance = 1.0;	
	
	filter->SetNumberOfIterations( numberOfIterations );
	filter->SetTimeStep( timeStep );
	filter->SetConductanceParameter( conductance );
  
	filter->Update();	/* take so long time....*/

/*
	typedef itk::RescaleIntensityImageFilter<PixelType, PixelType > RescaleFilterType;

	  RescaleFilterType::Pointer rescaler = RescaleFilterType::New();
	  rescaler->SetOutputMinimum(   0 );
	  rescaler->SetOutputMaximum( 255 );	

	rescaler->SetInput( filter->GetOutput() );
*/
	memcpy( pOutputData, filter->GetOutput()->GetBufferPointer(), sizeof(unsigned char)*volume_size );	
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20050426/ce800b8c/attachment.html


More information about the Insight-users mailing list