[Insight-users] ITK exception caught in main : itk::InvalidRequestedRegionError (0x82cb748)

charfeddine amir charfeddine_amir at yahoo.fr
Wed Feb 1 10:37:23 EST 2006


HI all
 i have this error and the program crash while triying to visualize Dicom Image.
 this program read all Dicom files belonging to the same serie, from a given directory.
 each file contain many slice of a fantom.
 I take the ShapeDetectionLevelSet program from the InsightApplications and edit it do that.
 i start with pushing the Load Button, I select a dicom directory containing files, then program read all the Dicom files belonging to the same serie( the first one found), and read the first Dicom file, then i can visualize it when i click on the Display Button (under Load button),
 then i move to the next Dicom file in serie with a counter (like fltk slider), and when i reclick on display, the program crash with the following message:
 
 ITK exception caught in main  
 
 itk::InvalidRequestedRegionError (0x82cb748)
 Location: "Image::PropagateRequestedRegion()"
 File: /usr/local/InsightToolkit-2.4.0/Code/Common/itkDataObject.cxx
 Line: 397
 Description: Requested region is (at least partially) outside the largest possible region.
 
 this is part of code i add:
 
 //function for loading the first serie in the directory dirname
 void
 ShapeDetectionLevelSetBase 
 ::LoadInputDir( const char * dirname )
 {
 
 if( !dirname )
   {
     return;
   }
  nameGenerator->SetDirectory( dirname );
  seriesUID = nameGenerator->GetSeriesUIDs();
  
  seriesIdentifier = seriesUID.begin()->c_str();
      
   
     fileNames = nameGenerator->GetFileNames( seriesIdentifier );
     FileNamesBegin = fileNames.begin();
     FileNamesItr = fileNames.end();
     FileNamesEnd = fileNames.end();
     
     ListCardinal=0;
     ListPosition=1;
     while( FileNamesItr != FileNamesBegin )
     {
      ListCardinal++;
      FileNamesItr--;
     }
  
   LoadCurrentImage();
 }
 
 //function for reading the first file in serie
 void
 ShapeDetectionLevelSetBase 
 ::LoadCurrentImage()
 {
  
   m_ImageReader->SetFileName( FileNamesItr->c_str());
   m_ImageReader->Update();
   m_InputImage=m_ImageReader->GetOutput();
 
   // Allocate an image of seeds of the same size
   InputImageType::RegionType region 
             = m_ImageReader->GetOutput()->GetLargestPossibleRegion();
 
   InputImageType::SizeType size = region.GetSize();
 
   for(unsigned int i=0; i<ImageDimension; i++)
     {
     if( size[i] < 10 )
       {
       this->ShowStatus("Image must be 3D and with at least 10 pixels along each Dimension.");
       itk::ExceptionObject excp;
       excp.SetDescription("Image must be 3D and with at least 10 pixels along each Dimension.");
       throw excp;
       }
     }
 
 
   m_SeedImage->SetRegions( region );
   m_SeedImage->Allocate();
   m_SeedImage->FillBuffer( itk::NumericTraits<SeedImageType::PixelType>::Zero );
 
   m_FastMarchingFilter->SetOutputSize( region.GetSize() );
 
 
   m_InputImageIsLoaded = true;
 }
 
 //function for reading the next file in serie
 void
 ShapeDetectionLevelSetBase 
 ::LoadNextImage( )
 {
 if ( FileNamesItr != FileNamesEnd )
 {
 FileNamesItr++;
 ListPosition++;
 m_ImageReader->SetFileName( FileNamesItr->c_str() );
 m_ImageReader->Update();
 m_InputImage=m_ImageReader->GetOutput();
 }
 
 //this->ShowInputImage();
 
 InputImageType::RegionType region 
             = m_ImageReader->GetOutput()->GetLargestPossibleRegion();
 
   InputImageType::SizeType size = region.GetSize();
 
   for(unsigned int i=0; i<ImageDimension; i++)
     {
     if( size[i] < 10 )
       {
       this->ShowStatus("Image must be 3D and with at least 10 pixels along each Dimension.");
       itk::ExceptionObject excp;
       excp.SetDescription("Image must be 3D and with at least 10 pixels along each Dimension.");
       throw excp;
       }
     }
 
 
   m_SeedImage->SetRegions( region );
   m_SeedImage->Allocate();
   m_SeedImage->FillBuffer( itk::NumericTraits<SeedImageType::PixelType>::Zero );
 
   m_FastMarchingFilter->SetOutputSize( region.GetSize() );
 }
 
 //function for reading the previous file in serie
 void
 ShapeDetectionLevelSetBase 
 ::LoadPrevImage( )
 {
 
 if ( FileNamesItr != FileNamesBegin )
 {
 FileNamesItr--;
 ListPosition--;
 m_ImageReader->SetFileName( FileNamesItr->c_str() );
 m_ImageReader->Update();
 m_InputImage=m_ImageReader->GetOutput();
 }
 
 //this->ShowInputImage();
 
 InputImageType::RegionType region 
             = m_ImageReader->GetOutput()->GetLargestPossibleRegion();
 
   InputImageType::SizeType size = region.GetSize();
 
   for(unsigned int i=0; i<ImageDimension; i++)
     {
     if( size[i] < 10 )
       {
       this->ShowStatus("Image must be 3D and with at least 10 pixels along each Dimension.");
       itk::ExceptionObject excp;
       excp.SetDescription("Image must be 3D and with at least 10 pixels along each Dimension.");
       throw excp;
       }
     }
 
 
   m_SeedImage->SetRegions( region );
   m_SeedImage->Allocate();
   m_SeedImage->FillBuffer( itk::NumericTraits<SeedImageType::PixelType>::Zero );
 
   m_FastMarchingFilter->SetOutputSize( region.GetSize() );
 
 }
 /********************************************************************************************/
 
 
 any comment is welcome
 thx
 Amir,
 
		
---------------------------------
 Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.Téléchargez la version beta.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20060201/2bf23bde/attachment.html


More information about the Insight-users mailing list