HI all<br> i have this error and the program crash while triying to visualize Dicom Image.<br> this program read all Dicom files belonging to the same serie, from a given directory.<br> each file contain many slice of a fantom.<br> I take the ShapeDetectionLevelSet program from the InsightApplications and edit it do that.<br> 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),<br> 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:<br> <br> ITK exception caught in main <br> <br> itk::InvalidRequestedRegionError (0x82cb748)<br> Location: "Image::PropagateRequestedRegion()"<br> File: /usr/local/InsightToolkit-2.4.0/Code/Common/itkDataObject.cxx<br>
Line: 397<br> Description: Requested region is (at least partially) outside the largest possible region.<br> <br> this is part of code i add:<br> <br> <span style="font-style: italic; text-decoration: underline;">//function for loading the first serie in the directory dirname</span><br> <span style="font-weight: bold;">void</span><br style="font-weight: bold;"> <span style="font-weight: bold;">ShapeDetectionLevelSetBase </span><br style="font-weight: bold;"> <span style="font-weight: bold;">::<span style="text-decoration: underline;">LoadInputDir</span>( const char * dirname )</span><br> {<br> <br> if( !dirname )<br> {<br> return;<br> }<br> nameGenerator->SetDirectory( dirname );<br> seriesUID = nameGenerator->GetSeriesUIDs();<br> <br> seriesIdentifier = seriesUID.begin()->c_str();<br> <br> <br> fileNames = nameGenerator->GetFileNames( seriesIdentifier );<br>
FileNamesBegin = fileNames.begin();<br> FileNamesItr = fileNames.end();<br> FileNamesEnd = fileNames.end();<br> <br> ListCardinal=0;<br> ListPosition=1;<br> while( FileNamesItr != FileNamesBegin )<br> {<br> ListCardinal++;<br> FileNamesItr--;<br> }<br> <br> LoadCurrentImage();<br> }<br> <br> <span style="text-decoration: underline; font-style: italic;">//function for reading the first file in serie</span><br> <span style="font-weight: bold;">void</span><br style="font-weight: bold;"> <span style="font-weight: bold;">ShapeDetectionLevelSetBase </span><br style="font-weight: bold;"> <span style="font-weight: bold;">::<span style="text-decoration: underline;">LoadCurrentImage</span>()</span><br style="font-weight: bold;"> {<br> <br>
m_ImageReader->SetFileName( FileNamesItr->c_str());<br> m_ImageReader->Update();<br> m_InputImage=m_ImageReader->GetOutput();<br> <br> // Allocate an image of seeds of the same size<br> InputImageType::RegionType region <br> = m_ImageReader->GetOutput()->GetLargestPossibleRegion();<br> <br> InputImageType::SizeType size = region.GetSize();<br> <br> for(unsigned int i=0; i<ImageDimension; i++)<br> {<br> if( size[i] < 10 )<br> {<br> this->ShowStatus("Image must be 3D and with at least 10 pixels along each Dimension.");<br> itk::ExceptionObject excp;<br> excp.SetDescription("Image must be 3D and with at least 10 pixels along each Dimension.");<br> throw excp;<br>
}<br> }<br> <br> <br> m_SeedImage->SetRegions( region );<br> m_SeedImage->Allocate();<br> m_SeedImage->FillBuffer( itk::NumericTraits<SeedImageType::PixelType>::Zero );<br> <br> m_FastMarchingFilter->SetOutputSize( region.GetSize() );<br> <br> <br> m_InputImageIsLoaded = true;<br> }<br> <br> <span style="text-decoration: underline; font-style: italic;">//function for reading the next file in serie</span><br> <span style="font-weight: bold;">void</span><br style="font-weight: bold;"> <span style="font-weight: bold;">ShapeDetectionLevelSetBase </span><br style="font-weight: bold;"> <span style="font-weight: bold;">::<span style="text-decoration: underline;">LoadNextImage</span>( )</span><br> {<br> if ( FileNamesItr != FileNamesEnd )<br> {<br> FileNamesItr++;<br> ListPosition++;<br> m_ImageReader->SetFileName( FileNamesItr->c_str() );<br> m_ImageReader->Update();<br>
m_InputImage=m_ImageReader->GetOutput();<br> }<br> <br> //this->ShowInputImage();<br> <br> InputImageType::RegionType region <br> = m_ImageReader->GetOutput()->GetLargestPossibleRegion();<br> <br> InputImageType::SizeType size = region.GetSize();<br> <br> for(unsigned int i=0; i<ImageDimension; i++)<br> {<br> if( size[i] < 10 )<br> {<br> this->ShowStatus("Image must be 3D and with at least 10 pixels along each Dimension.");<br> itk::ExceptionObject excp;<br> excp.SetDescription("Image must be 3D and with at least 10 pixels along each Dimension.");<br> throw excp;<br> }<br> }<br> <br> <br> m_SeedImage->SetRegions( region );<br>
m_SeedImage->Allocate();<br> m_SeedImage->FillBuffer( itk::NumericTraits<SeedImageType::PixelType>::Zero );<br> <br> m_FastMarchingFilter->SetOutputSize( region.GetSize() );<br> }<br> <br> <span style="text-decoration: underline; font-style: italic;">//function for reading the previous file in serie</span><br> <span style="font-weight: bold;">void</span><br style="font-weight: bold;"> <span style="font-weight: bold;">ShapeDetectionLevelSetBase </span><br style="font-weight: bold;"> <span style="font-weight: bold;">::<span style="text-decoration: underline;">LoadPrevImage</span>( )</span><br> {<br> <br> if ( FileNamesItr != FileNamesBegin )<br> {<br> FileNamesItr--;<br> ListPosition--;<br> m_ImageReader->SetFileName( FileNamesItr->c_str() );<br> m_ImageReader->Update();<br> m_InputImage=m_ImageReader->GetOutput();<br> }<br> <br> //this->ShowInputImage();<br> <br> InputImageType::RegionType region <br>
= m_ImageReader->GetOutput()->GetLargestPossibleRegion();<br> <br> InputImageType::SizeType size = region.GetSize();<br> <br> for(unsigned int i=0; i<ImageDimension; i++)<br> {<br> if( size[i] < 10 )<br> {<br> this->ShowStatus("Image must be 3D and with at least 10 pixels along each Dimension.");<br> itk::ExceptionObject excp;<br> excp.SetDescription("Image must be 3D and with at least 10 pixels along each Dimension.");<br> throw excp;<br> }<br> }<br> <br> <br> m_SeedImage->SetRegions( region );<br> m_SeedImage->Allocate();<br> m_SeedImage->FillBuffer( itk::NumericTraits<SeedImageType::PixelType>::Zero );<br> <br>
m_FastMarchingFilter->SetOutputSize( region.GetSize() );<br> <br> }<br> /********************************************************************************************/<br> <br> <br> any comment is welcome<br> thx<br> Amir,<br> <p>
                <hr size=1> Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.
<a href="http://us.rd.yahoo.com/messenger/mail_taglines/default/*http://fr.beta.messenger.yahoo.com">Téléchargez</a> la version beta.