[Insight-users] Distance Map
Luis Ibanez
luis.ibanez at kitware.com
Thu Aug 3 17:40:36 EDT 2006
Hi Kevin,
Thanks for letting us know about the size of your image.
It seems that the problem is at the level of the negotiation
of the pipeline between ITK and VTK.
Could you test your input image by using an ITK-only pipeline ?
You probably will need to convert your input image to one of
the many image file formats supported by ITK.
As a base code you could use the Examples:
Insight/Examples/Filtering/
DanielssonDistanceMapImageFilter.cxx
SignedDanielssonDistanceMapImageFilter.cxx
You will have to adapt their dimension and pixel type.
Please give this a try and let us know what you find.
Thanks
Luis
------------------
Luis Ibanez wrote:
>
> Hi Kevin,
>
> What is the size of your image in pixels ?
>
> Please let us know,
>
>
> Thanks
>
>
> Luis
>
>
> ------------------------
> Kevin H. Hobbs wrote:
>
>> I tried to use the attached code to produce a distance map for my almost
>> binary gray scale image. When I use the
>> SignedDanielssonDistanceMapImageFilter I can get some output but it uses
>> WAY to much memory. Whenever I try
>> ApproximateSignedDistanceMapImageFilter the program immediately throws
>> an exception that really doesn't help me much:
>>
>> [kevin at gargon stg_anatomy]$ time ./VTK2ITKDistanceMap
>> tmp/011105pd2_small_piece.vti tmp/dist_011105pd2_small_piece.vti 32 8
>> ERROR: In /home/kevin/kitware/VTK/Imaging/vtkImageImport.cxx, line 420
>> vtkImageImport (0x58c250): Calling UpdateDataCallback:
>> /home/kevin/kitware/Insight/Code/Common/itkMultiThreader.cxx:358:
>> itk::ERROR: MultiThreader(0x57f1f0): Exception occurred during
>> SingleMethodExecute
>>
>>
>> real 0m5.711s
>> user 0m2.928s
>> sys 0m0.400s
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> #include "vtkImageData.h"
>> #include "itkImage.h"
>>
>> #include "vtkITKUtility.h"
>>
>> #include "vtkXMLImageDataReader.h"
>>
>> #include "vtkImageExport.h"
>> #include "itkVTKImageImport.h"
>>
>> #include "itkBinaryThresholdImageFilter.h"
>> #include "itkApproximateSignedDistanceMapImageFilter.h"
>> #include "itkSignedDanielssonDistanceMapImageFilter.h"
>>
>> #include "itkVTKImageExport.h"
>> #include "vtkImageImport.h"
>>
>> #include "vtkXMLImageDataWriter.h"
>>
>> int main( int argc, char * argv[] )
>> {
>> if( argc < 5 ) { std::cerr << "Usage: "
>> << std::endl;
>> std::cerr << argv[0] << std::endl
>> << "\tinput_image_file" << std::endl
>> << "\toutput_image_file" << std::endl
>> << "\tlevel pieces" << std::endl;
>> return EXIT_FAILURE;
>> }
>>
>> char * input_image_file = argv[1];
>> char * output_image_file = argv[2];
>> const int level = atoi( argv[3] );
>> const int pieces = atoi( argv[4] );
>>
>> // Pixel Types
>> typedef float F_PixelType;
>> typedef unsigned char UC_PixelType;
>>
>> // Image Types
>> typedef itk::Image< F_PixelType, 3 > F_ImageType;
>> typedef itk::Image< UC_PixelType, 3 > UC_ImageType;
>>
>> // VTK Image Reader
>> vtkXMLImageDataReader * reader =
>> vtkXMLImageDataReader::New();
>> reader->SetFileName( input_image_file );
>>
>> // VTK Export
>> vtkImageExport * vtk_export = vtkImageExport::New();
>> vtk_export->SetInputConnection( reader->GetOutputPort() );
>>
>> // ITK Import
>> typedef itk::VTKImageImport< UC_ImageType > ITKImportType;
>> ITKImportType::Pointer itk_import = ITKImportType::New();
>> ConnectPipelines( vtk_export, itk_import );
>>
>> // ITK Binary Threshold
>> typedef itk::BinaryThresholdImageFilter < UC_ImageType,
>> UC_ImageType > ThreshFilterType;
>> ThreshFilterType::Pointer thresh_filter =
>> ThreshFilterType::New();
>> thresh_filter->SetInsideValue( 0 );
>> thresh_filter->SetOutsideValue( 255 );
>> thresh_filter->SetLowerThreshold( level );
>> thresh_filter->SetUpperThreshold( 255 );
>> thresh_filter->SetInput( itk_import->GetOutput() );
>>
>> // ITK Distance Filter
>> typedef itk::ApproximateSignedDistanceMapImageFilter
>> < UC_ImageType, F_ImageType > DistanceFilterType;
>> //typedef itk::SignedDanielssonDistanceMapImageFilter
>> // < UC_ImageType, F_ImageType > DistanceFilterType;
>> DistanceFilterType::Pointer distance_filter =
>> DistanceFilterType::New();
>> distance_filter->SetInsideValue( 0 );
>> distance_filter->SetOutsideValue( 255 );
>> distance_filter->SetInput( thresh_filter->GetOutput() );
>>
>> // ITK Export
>> typedef itk::VTKImageExport< F_ImageType > ITKExportType;
>> ITKExportType::Pointer itk_export = ITKExportType::New();
>> itk_export->SetInput( distance_filter->GetOutput() );
>>
>> // VTK Import
>> vtkImageImport * vtk_import = vtkImageImport::New();
>> ConnectPipelines( itk_export, vtk_import );
>>
>> // VTK Writer
>> vtkXMLImageDataWriter * writer =
>> vtkXMLImageDataWriter::New();
>> writer->SetFileName( output_image_file );
>> writer->SetNumberOfPieces( pieces );
>> writer->SetInputConnection( vtk_import->GetOutputPort() );
>>
>> writer->Update();
>>
>> return 0;
>> }
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Insight-users mailing list
>> Insight-users at itk.org
>> http://www.itk.org/mailman/listinfo/insight-users
>
>
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>
>
More information about the Insight-users
mailing list