[Insight-users] Surface extraction seg. fault at meshSource->Update()

Luis Ibanez luis.ibanez at kitware.com
Mon Apr 30 18:18:41 EDT 2007


Hi Catherine,

  Does your image CT0001.dcm contain multiple slices ?


Otherwise it is going to be considered as a 1 slice
3D image, and it is reasonable that it will fail to
produce a 3D surface when passed as input to the
BinaryMask3DMeshSource.


Please let us know how many pixels along each one
of the three dimensions does CT0001.dcm has.



    Regards,


       Luis



--------------------------
Catherine Peloquin wrote:
> I am trying to get a version of the example surface extraction code 
> running.  I had problems with the CMakeLists.txt file, but that has been 
> resolved.  My problem now is that I am getting a segmentation fault at 
> the line "meshSource->Update()".  I tried using .ima files, and .dcm 
> files located in the same directory as my .cxx and CMakeLists files.  I 
> added a try/catch block around this line as Luis suggested and re-built 
> the example, but the program still faults out at that location.  I am 
> running the executable with the command "SurfaceExtraction CT0001.dcm 
> 400". 
> 
> The relevant .cxx file code is as follows:
> 
> //Surface Extraction code modified from ITK Surface Extraction Example 
> included in ITK build
> #if defined(_MSC_VER)
> #pragma warning ( disable : 4786 )
> #endif
> 
> #ifdef __BORLANDC__
> #define ITK_LEAN_AND_MEAN
> #endif
> 
> #include "itkImageFileReader.h"
> #include "itkBinaryMask3DMeshSource.h"
> #include " itkImage.h"
> #include "itkMesh.h"
> #include <iostream>
> using namespace std;
> 
> int main(int argc, char * argv[] )
> {
> 
>   if( argc < 3 )
>     {
>     std::cerr << "Usage: IsoSurfaceExtraction  inputImageFile   
> objectValue " << std::endl;
>     return EXIT_FAILURE;
>     }
> 
>   const unsigned int Dimension = 3;
>   typedef unsigned char  PixelType;
> 
>   typedef itk::Image< PixelType, Dimension >   ImageType;
>   typedef itk::ImageFileReader< ImageType >    ReaderType;
>   ReaderType::Pointer reader = ReaderType::New();
>   reader->SetFileName( argv[1] );
> 
>   try
>     {
>     reader->Update();
>     }
>   catch( itk::ExceptionObject & exp )
>     {
>     std::cerr << "Exception thrown while reading the input file " << 
> std::endl;
>     std::cerr << exp << std::endl;
>     return EXIT_FAILURE;
>     }
> 
>   typedef itk::Mesh<double>                         MeshType;
>   typedef itk::BinaryMask3DMeshSource< ImageType, MeshType >   
> MeshSourceType;
>   MeshSourceType::Pointer meshSource = MeshSourceType::New();
> 
>   const PixelType objectValue = static_cast<PixelType>( atof( argv[2] ) );
> 
>   meshSource->SetObjectValue( objectValue );
> 
>     cout << "Before meshSource input set." << endl;
>     try
>       {
>           meshSource->SetInput( reader->GetOutput() );
>         }
>       catch( itk::ExceptionObject & exp )
>       {
>         std::cerr << "Exception thrown during setting mesh input() " << 
> std::endl;
>         std::cerr << exp << std::endl;
>         return EXIT_FAILURE;
>         }
> 
>     cout << "Before meshSource update" << endl;
>   try
>     {
>     meshSource->Update();  //--------------------------SEGMENTATION 
> FAULT HERE--------------------------------------------
>     }
>   catch( itk::ExceptionObject & exp )
>     {
>     cerr << "Exception thrown during Update() " << std::endl;
>     cerr << exp << std::endl;
>     return EXIT_FAILURE;
>     }
> 
>   cout << "Nodes = " << meshSource->GetNumberOfNodes() << std::endl;
>   cout << "Cells = " << meshSource->GetNumberOfCells() << std::endl;
> 
>   return EXIT_SUCCESS;
> }
> 
> Does anyone have any suggestions?
> 
> Thanks,
> Catherine
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> 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