[Insight-users] replace DanielssonDistanceMapImageFilter by SignedMaurerDistanceMapImageFilter fails

Matt McCormick matt.mccormick at kitware.com
Wed Oct 9 11:04:21 EDT 2013


Hi Oliver,

Does copying the output Image (distanceMapper->GetOutput() ) to your
pointer instead of trying to SetImportPointer() help?

Thanks,
Matt

On Wed, Oct 9, 2013 at 8:34 AM, Oliver <mail at oliwe.com> wrote:
> 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.
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users


More information about the Insight-users mailing list