[Insight-users] error during extracting slice from 3D image

Bradley Lowekamp blowekamp at mail.nih.gov
Tue Mar 13 17:53:44 EDT 2012


Hello,

Your error message indicates that the extract direction or orientation matrix is invalid and singular.

You should look at the DirectionCollapse option for the filter:

http://www.itk.org/Doxygen/html/classitk_1_1ExtractImageFilter.html#a5b3bcfa552d8ad7cf509e32209aadc13

Brad 

On Mar 13, 2012, at 5:48 PM, alaamegawer wrote:

> Hi all 
> 
> 
> actually i  want to extract slice from 3D image , in x or y dir , i used itk
> example . and it's working great if i extract in z direction but if i try to
> extract in x or y direction i have run time error 
> 
> the error is ,  itk::error : extractimagefilter: invalid submatrix extracted
> for collapsed direction 
> 
> 
> 
> #include "itkImageFileReader.h"
> #include "itkImageFileWriter.h"
> #include "itkExtractImageFilter.h"
> #include "itkImage.h"
> 
> 
> int main( int argc, char ** argv )
> {
>  typedef signed char        InputPixelType;
>  typedef signed char        OutputPixelType;
> 
>  typedef itk::Image< InputPixelType,  3 >    InputImageType;
>  typedef itk::Image< OutputPixelType, 2 >    OutputImageType;
>  typedef itk::ImageFileReader< InputImageType  >  ReaderType;
>  typedef itk::ImageFileWriter< OutputImageType >  WriterType;
> 
>  const char * inputFilename  =
> "C:/Users/Administrator/Desktop/test/src/brainweb1e1a10f20.mha";
>  const char * outputFilename =
> "C:/Users/Administrator/Desktop/test/src/brainweb.mha";
> 
>  ReaderType::Pointer reader = ReaderType::New();
>  WriterType::Pointer writer = WriterType::New();
> 
>  reader->SetFileName( inputFilename  );
>  writer->SetFileName( outputFilename );
> 
>  typedef itk::ExtractImageFilter< InputImageType, OutputImageType >
> FilterType;
>  FilterType::Pointer filter = FilterType::New();
>  filter->InPlaceOn();
>  filter->SetDirectionCollapseToSubmatrix();
> 
>  reader->UpdateOutputInformation();
>  InputImageType::RegionType inputRegion =
>           reader->GetOutput()->GetLargestPossibleRegion();
> 
>  InputImageType::SizeType size = inputRegion.GetSize();
>  size[0] = 0;
> 
>  InputImageType::IndexType start = inputRegion.GetIndex();
>  const unsigned int sliceNumber = 0;
>  start[0] = sliceNumber;
> 
>  InputImageType::RegionType desiredRegion;
>  desiredRegion.SetSize(  size  );
>  desiredRegion.SetIndex( start );
> 
>  filter->SetExtractionRegion( desiredRegion );
> 
>  filter->SetInput( reader->GetOutput() );
>  writer->SetInput( filter->GetOutput() );
> 
>  try
>    {
>    writer->Update();
>    }
>  catch( itk::ExceptionObject & err )
>    {
>    std::cerr << "ExceptionObject caught !" << std::endl;
>    std::cerr << err << std::endl;
>    return EXIT_FAILURE;
>    }
> 
>  return EXIT_SUCCESS;
> }
> 
> 
> please help me if u can 
> 
> --
> View this message in context: http://itk-insight-users.2283740.n2.nabble.com/error-during-extracting-slice-from-3D-image-tp7370067p7370067.html
> Sent from the ITK Insight Users mailing list archive at Nabble.com.
> _____________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> 
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
> 
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users

========================================================
Bradley Lowekamp  
Medical Science and Computing for
Office of High Performance Computing and Communications
National Library of Medicine 
blowekamp at mail.nih.gov



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120313/7338140e/attachment.htm>


More information about the Insight-users mailing list