[Insight-users] a overflow maked by "itkBinaryMask3DMeshSource.txx"

Luis Ibanez luis.ibanez at kitware.com
Wed Dec 10 15:56:53 EST 2008


Hi hubaoping

It is likely that your code is not yet
reading the DICOM series correctly.

Please do the following:


   Before the line:


 >     meshSource->Update();

   insert the following lines:

    try
     {
     m_reader->Update();
     }
    catch( itk::ExceptionObject & excp )
     {
     std::cerr << excp << std::endl;
     exit(1);
     }

    m_reader->GetOutput()->Print( std::cout );


This should print the basic characteristics of the image.

Please post this output to the mailing list, and we can
follow from there...


    Thanks


       Luis



-----------------
hubaoping wrote:
> Hello , Luis,
> There  are some pseudocode from my project, and I  hope you can have a 
> test with the example "SurfaceExtraction".when I run the 
> console application "SurfaceExtraction.exe",it will break and has a 
> warnning message  "the 0x********* memory van not be read!" I call this 
> application with the following arguments:
>    SurfaceExtraction.exe  F:\dicom  200
> The two parameters I input in the command lines are the directory of 
> DICOM image and a float number(100).I think the logic error in the 
> "itkBinaryMask3DMeshSource.txx" will take a overflow.
>  
> #include "itkGDCMImageIO.h"
> #include "itkGDCMSeriesFileNames.h"
> #include "itkImageSeriesReader.h"
> #include "itkImageFileWriter.h"
> #include "itkMesh.h"
> #include "itkBinaryMask3DMeshSource.h"
> ////   defined variable  ///////// 
>        typedef signed short    PixelType;
>  typedef itk::Image< PixelType, 3 >         ImageType;
>  typedef itk::ImageSeriesReader< ImageType >        ReaderType;
>  typedef itk::GDCMImageIO       ImageIOType;
>  typedef itk::GDCMSeriesFileNames NamesGeneratorType;
>  typedef std::vector< std::string >    SeriesIdContainer;
>  std::string seriesIdentifier;
>  typedef std::vector< std::string >   FileNamesContainer;
>        FileNamesContainer fileNames;
>  typedef itk::Mesh<float,3>                         MeshType;
>       typedef itk::BinaryMask3DMeshSource< ImageType, MeshType >   
> MeshSourceType;
> private:
>  ReaderType::Pointer  m_reader;
>  ImageIOType::Pointer dicomIO;
>  NamesGeneratorType::Pointer nameGenerator;
>  MeshSourceType::Pointer meshSource;
> public:
>  static MeshType::Pointer mesh;
> 
> ////   initialization   ////
>  m_reader = ReaderType::New();
>  dicomIO = ImageIOType::New();
>  m_reader->SetImageIO( dicomIO );
>    nameGenerator = NamesGeneratorType::New();
>    meshSource = MeshSourceType::New();
> ////  read some dicom image from a directory  like  "F:\dicom"  ///////
>          nameGenerator->SetUseSeriesDetails( true );
>  nameGenerator->AddSeriesRestriction("0008|0021" );
>  nameGenerator->SetDirectory( "F:\dicom" );
>  const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs();
>   
>        SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();
>       SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();
>       seriesIdentifier = seriesUID.begin()->c_str();
>     fileNames = nameGenerator->GetFileNames( seriesIdentifier );
>     m_reader->SetFileName( fileNames[0].c_str());
> /////  get a mesh ///////
>     const PixelType objectValue = static_cast<PixelType>(200);
>  
>  meshSource->SetObjectValue( objectValue);
>  meshSource->SetInput( m_reader->GetOutput() );
>  
>     meshSource->Update();
>  
>    mesh = meshSource->GetOutput();
>  
> 
> --
> ºú±¦Æ½
> 
> ÔÚ2008-12-03 06:42:45£¬"Luis Ibanez" <luis.ibanez at kitware.com> дµÀ£º
>>Hi hubaoping
>>
>>The internal implementation of "itkBinaryMask3DMeshSource" certainly
>>deserves to be rewritten.
>>
>>However, we have usually been able to use this filter.
>>
>>Could you please provide the source code of the file from which you
>>are using the filter, and provide a description of the input image
>>that you are passing to it ?
>>
>>
>>     Thanks
>>
>>
>>         Luis
>>
>>
>>
>>
>>-------------------
>>hubaoping wrote:
>>>  Hi,
>>>     When I use the "itkBinaryMask3DMeshSource" to creat a mesh,compliled 
>>>  without error.But it cannot run.There is a  warning likes  "0x******** 
>>> cannot be read"and break at the point in the"itkBinaryMask3DMeshSource.txx "
>>>    So I look over the "itkBinaryMask3DMeshSource.txx ",the code below 
>>> make me confused.
>>>   //////////////////////
>>>  InputImageIterator it1( m_InputImage, m_InputImage->GetBufferedRegion() );
>>>   InputImageIterator it2( m_InputImage, m_InputImage->GetBufferedRegion() );
>>>   InputImageIterator it3( m_InputImage, m_InputImage->GetBufferedRegion() );
>>>   InputImageIterator it4( m_InputImage, m_InputImage->GetBufferedRegion() );
>>>   it1.GoToBegin();
>>>   it2.GoToBegin();
>>>   it3.GoToBegin();
>>>   it4.GoToBegin();
>>>   InputImageSizeType inputImageSize = 
>>> m_InputImage->GetBufferedRegion().GetSize();
>>>   m_ImageWidth  = inputImageSize[0];
>>>   m_ImageHeight = inputImageSize[1];
>>>   m_ImageDepth  = inputImageSize[2];
>>>   int frame = m_ImageWidth * m_ImageHeight;
>>>   int row = m_ImageWidth;
>>>  
>>>   int i = 0;
>>>   int j;
>>>   while ( i < frame )
>>>     {
>>>     ++it3;
>>>     ++it1;
>>>     i++;
>>>     }
>>>   i = 0;
>>>   while ( i < row )
>>>     {
>>>     ++it2;
>>>     ++it4;
>>>     i++;
>>>     }
>>>  
>>> while ( !it4.IsAtEnd() )
>>>     {
>>>     vertexindex = 0;
>>>     if ( it1.Value() == m_ObjectValue ) vertexindex += 1;
>>>     if ( it2.Value() == m_ObjectValue ) vertexindex += 8;
>>>     if ( it3.Value() == m_ObjectValue ) vertexindex += 16;
>>>     if ( it4.Value() == m_ObjectValue ) vertexindex += 128;
>>>     ++it1;
>>>     ++it2;
>>>     ++it3;
>>>     ++it4;
>>> ///////////////////////////////////////////////////
>>> If m_ImageWidth = m_ImageHeight = 512, m_ImageDepth  = 1,so   frame = 
>>> 512*512 =262144,row = 512. Well,after
>>> /while ( i < frame )
>>>     {
>>>     ++it3;
>>>     ++it4;
>>>     i++;
>>>     }/
>>> /
>>> 
>>> /the offset of it4 or it3 is *262144.*then
>>> /while ( i < row )
>>>     {
>>>     ++it2;
>>>     ++it4;
>>>     i++;
>>>     };/
>>> the offset of it4 is *262144+512 =262656.*but the it4.IsAtEnd() is 
>>> *262144.so the lines *while ( !it4.IsAtEnd() )
>>> will run and not stop. and the offsets of the iterators will  overflow.
>>> --
>>> ºú±¦Æ½
>>> 
>>> 
>>> ------------------------------------------------------------------------
>>> ÍøÒ×Ãâ·ÑÓÊ£¬È«Çò×î´óµÄÖÐÎÄÃâ·ÑÓÊÏä <http://www.yeah.net>
>>> 
>>> 
>>> ------------------------------------------------------------------------
>>> 
>>> _______________________________________________
>>> Insight-users mailing list
>>> Insight-users at itk.org
>>> http://www.itk.org/mailman/listinfo/insight-users
> 
> 
> 
> ------------------------------------------------------------------------
> ÍøÒ×Ãâ·ÑÓÊ£¬È«Çò×î´óµÄÖÐÎÄÃâ·ÑÓÊÏä <http://www.yeah.net>


More information about the Insight-users mailing list