<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&nbsp;</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 &nbsp;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 , &nbsp;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> &nbsp;typedef signed char &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InputPixelType;<br> &nbsp;typedef signed char &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OutputPixelType;<br><br> &nbsp;typedef itk::Image&lt; InputPixelType, &nbsp;3 &gt; &nbsp;&nbsp;&nbsp;InputImageType;<br> &nbsp;typedef itk::Image&lt; OutputPixelType, 2 &gt; &nbsp;&nbsp;&nbsp;OutputImageType;<br> &nbsp;typedef itk::ImageFileReader&lt; InputImageType &nbsp;&gt; &nbsp;ReaderType;<br> &nbsp;typedef itk::ImageFileWriter&lt; OutputImageType &gt; &nbsp;WriterType;<br><br> &nbsp;const char * inputFilename &nbsp;=<br>"C:/Users/Administrator/Desktop/test/src/brainweb1e1a10f20.mha";<br> &nbsp;const char * outputFilename =<br>"C:/Users/Administrator/Desktop/test/src/brainweb.mha";<br><br> &nbsp;ReaderType::Pointer reader = ReaderType::New();<br> &nbsp;WriterType::Pointer writer = WriterType::New();<br><br> &nbsp;reader-&gt;SetFileName( inputFilename &nbsp;);<br> &nbsp;writer-&gt;SetFileName( outputFilename );<br><br> &nbsp;typedef itk::ExtractImageFilter&lt; InputImageType, OutputImageType &gt;<br>FilterType;<br> &nbsp;FilterType::Pointer filter = FilterType::New();<br> &nbsp;filter-&gt;InPlaceOn();<br> &nbsp;filter-&gt;SetDirectionCollapseToSubmatrix();<br><br> &nbsp;reader-&gt;UpdateOutputInformation();<br> &nbsp;InputImageType::RegionType inputRegion =<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reader-&gt;GetOutput()-&gt;GetLargestPossibleRegion();<br><br> &nbsp;InputImageType::SizeType size = inputRegion.GetSize();<br> &nbsp;size[0] = 0;<br><br> &nbsp;InputImageType::IndexType start = inputRegion.GetIndex();<br> &nbsp;const unsigned int sliceNumber = 0;<br> &nbsp;start[0] = sliceNumber;<br><br> &nbsp;InputImageType::RegionType desiredRegion;<br> &nbsp;desiredRegion.SetSize( &nbsp;size &nbsp;);<br> &nbsp;desiredRegion.SetIndex( start );<br><br> &nbsp;filter-&gt;SetExtractionRegion( desiredRegion );<br><br> &nbsp;filter-&gt;SetInput( reader-&gt;GetOutput() );<br> &nbsp;writer-&gt;SetInput( filter-&gt;GetOutput() );<br><br> &nbsp;try<br> &nbsp;&nbsp;&nbsp;{<br> &nbsp;&nbsp;&nbsp;writer-&gt;Update();<br> &nbsp;&nbsp;&nbsp;}<br> &nbsp;catch( itk::ExceptionObject &amp; err )<br> &nbsp;&nbsp;&nbsp;{<br> &nbsp;&nbsp;&nbsp;std::cerr &lt;&lt; "ExceptionObject caught !" &lt;&lt; std::endl;<br> &nbsp;&nbsp;&nbsp;std::cerr &lt;&lt; err &lt;&lt; std::endl;<br> &nbsp;&nbsp;&nbsp;return EXIT_FAILURE;<br> &nbsp;&nbsp;&nbsp;}<br><br> &nbsp;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">&nbsp;</span><span class="Apple-converted-space">&nbsp;</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">&nbsp;</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>