[Insight-users] replace DanielssonDistanceMapImageFilter by SignedMaurerDistanceMapImageFilter fails

Oliver mail at oliwe.com
Wed Oct 9 04:34:31 EDT 2013


Hi, 

the attached code works fine with DanielssonDistanceMapImageFilter.
If I replace DanielssonDistanceMapImageFilter by
SignedMaurerDistanceMapImageFilter or
ApproximateSignedDistanceMapImageFilter the function fails.
Can someone give me any hints?

Oliver

template <int VDimension>
int danielssonDistanceMap(const char* logfilename, unsigned char*
imageinput, double* pspacing, int* sizeimage, float* outputimage)
{
	// append to a output to logfile
    if (logfilename!=0)
	{
        freopen( logfilename, "a", stdout );
        freopen( logfilename, "a", stderr );
    }

	std::cout << "danielssonDistanceMap [" << std::endl;
    
    const unsigned int Dimension = VDimension;
    std::cout << "Dimension=" << Dimension << std::endl;

    typedef unsigned char InputPixelType;
	typedef itk::Image< InputPixelType, Dimension >  InputImageType;

	typedef float OutputPixelType;
	typedef itk::Image < OutputPixelType, Dimension >  OutputImageType;

    typedef itk::ImportImageFilter< InputPixelType, Dimension >
ImportFilterType;
	ImportFilterType::Pointer ImageImportFilter = 0;
    typename InputImageType::Pointer p_imageinput;
    int totalNumberofPixels=sizeimage[0]*sizeimage[1];
    if (Dimension>2)
        totalNumberofPixels*=sizeimage[2];
    if (imageinput!=0)
	{
        ImageImportFilter = ImportFilterType::New();
        InputPixelType* pixelData= static_cast<InputPixelType*>( imageinput
);
        bool importImageFilterWillOwnTheBuffer=false;
		ImageImportFilter->SetImportPointer( pixelData, totalNumberofPixels,
			importImageFilterWillOwnTheBuffer );
		ImageImportFilter->SetSpacing( pspacing );
		std::cout << "Spacing=" << pspacing[0] << " " << pspacing[1] << " " 
			<< pspacing[2] << std::endl;
        ImportFilterType::SizeType size_image;
		size_image[0] = sizeimage[0]; // size along X
		size_image[1] = sizeimage[1];// size along Y
        if (Dimension>2)
            size_image[2] = sizeimage[2]; // size along Z
		ImportFilterType::IndexType start_image;
        //define offset of zero
		start_image.Fill( 0 );
		ImportFilterType::RegionType region_image;
		region_image.SetIndex( start_image );
		region_image.SetSize( size_image );
		ImageImportFilter->SetRegion( region_image );
        ImageImportFilter->Update();
        p_imageinput = ImageImportFilter->GetOutput() ;
        p_imageinput->DisconnectPipeline();
    }

	typedef itk::DanielssonDistanceMapImageFilter < InputImageType,
OutputImageType> DistanceMapper;
	DistanceMapper::Pointer distanceMapper = DistanceMapper::New();
	distanceMapper->SetInput(p_imageinput);
	distanceMapper->SetUseImageSpacing(true);

distanceMapper->GetOutput()->GetPixelContainer()->SetContainerManageMemory(false);

distanceMapper->GetOutput()->GetPixelContainer()->SetImportPointer(outputimage,totalNumberofPixels,false);
	distanceMapper->Update();

	std::cout << "danielssonDistanceMap ]" << std::endl;

	return 1;
}



--
View this message in context: http://itk-users.7.n7.nabble.com/replace-DanielssonDistanceMapImageFilter-by-SignedMaurerDistanceMapImageFilter-fails-tp32509.html
Sent from the ITK - Users mailing list archive at Nabble.com.


More information about the Insight-users mailing list