<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello,<div><br></div><div>Your error message indicates that the extract direction or orientation matrix is invalid and singular.</div><div><br></div><div>You should look at the DirectionCollapse option for the filter:</div><div><br></div><div><a href="http://www.itk.org/Doxygen/html/classitk_1_1ExtractImageFilter.html#a5b3bcfa552d8ad7cf509e32209aadc13">http://www.itk.org/Doxygen/html/classitk_1_1ExtractImageFilter.html#a5b3bcfa552d8ad7cf509e32209aadc13</a></div><div><br></div><div>Brad </div><div><br><div><div>On Mar 13, 2012, at 5:48 PM, alaamegawer wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Hi all <br><br><br>actually i want to extract slice from 3D image , in x or y dir , i used itk<br>example . and it's working great if i extract in z direction but if i try to<br>extract in x or y direction i have run time error <br><br>the error is , itk::error : extractimagefilter: invalid submatrix extracted<br>for collapsed direction <br><br><br><br>#include "itkImageFileReader.h"<br>#include "itkImageFileWriter.h"<br>#include "itkExtractImageFilter.h"<br>#include "itkImage.h"<br><br><br>int main( int argc, char ** argv )<br>{<br> typedef signed char InputPixelType;<br> typedef signed char OutputPixelType;<br><br> typedef itk::Image< InputPixelType, 3 > InputImageType;<br> typedef itk::Image< OutputPixelType, 2 > OutputImageType;<br> typedef itk::ImageFileReader< InputImageType > ReaderType;<br> typedef itk::ImageFileWriter< OutputImageType > WriterType;<br><br> const char * inputFilename =<br>"C:/Users/Administrator/Desktop/test/src/brainweb1e1a10f20.mha";<br> const char * outputFilename =<br>"C:/Users/Administrator/Desktop/test/src/brainweb.mha";<br><br> ReaderType::Pointer reader = ReaderType::New();<br> WriterType::Pointer writer = WriterType::New();<br><br> reader->SetFileName( inputFilename );<br> writer->SetFileName( outputFilename );<br><br> typedef itk::ExtractImageFilter< InputImageType, OutputImageType ><br>FilterType;<br> FilterType::Pointer filter = FilterType::New();<br> filter->InPlaceOn();<br> filter->SetDirectionCollapseToSubmatrix();<br><br> reader->UpdateOutputInformation();<br> InputImageType::RegionType inputRegion =<br> reader->GetOutput()->GetLargestPossibleRegion();<br><br> InputImageType::SizeType size = inputRegion.GetSize();<br> size[0] = 0;<br><br> InputImageType::IndexType start = inputRegion.GetIndex();<br> const unsigned int sliceNumber = 0;<br> start[0] = sliceNumber;<br><br> InputImageType::RegionType desiredRegion;<br> desiredRegion.SetSize( size );<br> desiredRegion.SetIndex( start );<br><br> filter->SetExtractionRegion( desiredRegion );<br><br> filter->SetInput( reader->GetOutput() );<br> writer->SetInput( filter->GetOutput() );<br><br> try<br> {<br> writer->Update();<br> }<br> catch( itk::ExceptionObject & err )<br> {<br> std::cerr << "ExceptionObject caught !" << std::endl;<br> std::cerr << err << std::endl;<br> return EXIT_FAILURE;<br> }<br><br> return EXIT_SUCCESS;<br>}<br><br><br>please help me if u can <br><br>--<br>View this message in context: <a href="http://itk-insight-users.2283740.n2.nabble.com/error-during-extracting-slice-from-3D-image-tp7370067p7370067.html">http://itk-insight-users.2283740.n2.nabble.com/error-during-extracting-slice-from-3D-image-tp7370067p7370067.html</a><br>Sent from the ITK Insight Users mailing list archive at <a href="http://Nabble.com">Nabble.com</a>.<br>_____________________________________<br>Powered by <a href="http://www.kitware.com">www.kitware.com</a><br><br>Visit other Kitware open-source projects at<br><a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br><br>Kitware offers ITK Training Courses, for more information visit:<br>http://www.kitware.com/products/protraining.php<br><br>Please keep messages on-topic and check the ITK FAQ at:<br>http://www.itk.org/Wiki/ITK_FAQ<br><br>Follow this link to subscribe/unsubscribe:<br>http://www.itk.org/mailman/listinfo/insight-users<br></div></blockquote></div><br><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">========================================================</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">Bradley Lowekamp<span class="Apple-converted-space"> </span><span class="Apple-converted-space"> </span></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">Medical Science and Computing for</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">Office of High Performance Computing and Communications</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">National Library of Medicine<span class="Apple-converted-space"> </span></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; "><a href="mailto:blowekamp@mail.nih.gov">blowekamp@mail.nih.gov</a></font></p><br class="Apple-interchange-newline"></span></div></span></span><br class="Apple-interchange-newline">
</div>
<br></div></body></html>