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

Luis Ibanez luis.ibanez at kitware.com
Tue May 1 06:29:54 EDT 2007


Hi Catherine,

Thanks for letting us know about the size of your image.

Since your image is indeed a 2D image, the filter that
you may want to use is the:


        itkContourExtractor2DImageFilter


This filter was contributed to ITK through a paper
submitted to the Insight Journal:

http://insight-journal.org/dspace/handle/1926/165

You will find the code of this filter in the directory:


         Insight/Code/Review

This code is an improved style version from the one in
the paper. It also was tested to 100% code coverage.


In order to find this filter you will need a version
of ITK 3.2 or later (e.g. CVS).


Please let us know if you find any problems using this
class.


As a user of the class you are also *strongly encouraged*
to submit a review to the paper in the Insight Journal.

The best qualified reviewers are those who *actually* try
the software, since they are the only ones that are verifying
the reproducibility of papers. Any other kind of review is
and empty ritual akin to the Aristotelian natural philosophy.



    Thanks


       Luis



------------------------------
Catherine Peloquin wrote:
> My image only contains one slice. It has 512 rows and 512 columns.
>  
> Catherine
> 
>  
> On 4/30/07, *Luis Ibanez* <luis.ibanez at kitware.com 
> <mailto:luis.ibanez at kitware.com>> wrote:
> 
> 
>     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 <mailto:Insight-users at itk.org>
>      > http://www.itk.org/mailman/listinfo/insight-users
> 
> 


More information about the Insight-users mailing list