<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
.MsoPapDefault
        {mso-style-type:export-only;
        mso-margin-top-alt:auto;
        mso-margin-bottom-alt:auto;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=DE-AT link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Hi Sundar,<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I use the eigenvalue analysis too. So i cross verified with my code whether you were missing something. My code is:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; typedef itk::SymmetricEigenAnalysis &lt; HessianRecursiveGaussianFilterType::OutputImageType::PixelType, VectorPixelType, EV_PixelType &gt; EigAnalysisType;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //set eigen analysis<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EigAnalysisType eig;<o:p></o:p></span></p><p class=MsoNormal style='text-autospace:none'><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style='background:red;mso-highlight:red'>eig.SetDimension( 3 );</span><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; eig.SetOrderEigenMagnitudes( true );<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>I found that the input matrix dimension was not set. Please check whether this is causing the error.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>All the best.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>Kana<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p>&nbsp;</o:p></span></p><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> insight-users-bounces@itk.org [mailto:insight-users-bounces@itk.org] <b>On Behalf Of </b>Sundaresan R<br><b>Sent:</b> 22 February 2011 22:58<br><b>To:</b> insight-users@itk.org<br><b>Subject:</b> [Insight-users] EigenVector Computation<o:p></o:p></span></p></div><p class=MsoNormal><span lang=EN-GB><o:p>&nbsp;</o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Hi<br><br>I'm computing the Hessians and then use SymmetricEigenAnalysis to compute the eigenVectors as follows:<br>I get a segmentation fault at the call to ComputeEigenValuesAndVectors method. Can anyone help me fix this issue?<br><br>Thanks,<br>Sundar<br><br>**************************************************************************************<br>&nbsp;<br>#include &quot;itkHessianRecursiveGaussianImageFilter.h&quot; <br>#include &quot;itkSymmetricEigenAnalysis.h&quot;<br>#include &quot;itkSymmetricEigenAnalysisImageFilter.h&quot; <br>#include &quot;itkSymmetricSecondRankTensor.h&quot; <br>#include &quot;itkCastImageFilter.h&quot; <br>#include &quot;itkImage.h&quot; <br>#include &quot;itkImageFileReader.h&quot; <br>#include &quot;itkImageFileWriter.h&quot; <br>#include &lt;iostream&gt;<br><br>&nbsp;<br>&nbsp; const&nbsp;&nbsp; unsigned int Dimension = 3; <br>&nbsp; typedef double&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InputPixelType; <br>&nbsp; typedef double&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; OutputPixelType; <br>&nbsp; typedef itk::Image&lt; InputPixelType, Dimension &gt;&nbsp; InputImageType; <br>&nbsp; typedef itk::Image&lt; OutputPixelType, Dimension &gt; OutputImageType; <br>&nbsp; typedef itk::ImageFileReader&lt; InputImageType &gt;&nbsp; ReaderType; <br>&nbsp; typedef itk::ImageFileWriter&lt; OutputImageType &gt; WriterType; <br>&nbsp; typedef itk::HessianRecursiveGaussianImageFilter&lt; InputImageType &gt; HessianFilterType; <br>&nbsp; typedef itk::Vector&lt; InputPixelType, Dimension &gt; VectorType;<br>&nbsp; typedef itk::Image&lt; VectorType, Dimension &gt; VectorImageType; <br>&nbsp; typedef itk::Matrix&lt; InputPixelType, Dimension, Dimension &gt; MatrixType;<br>&nbsp; typedef itk::Image&lt; MatrixType, Dimension &gt; MatrixImageType;<br>&nbsp; typedef itk::ImageRegionConstIterator&lt; MatrixImageType &gt; MatrixIteratorType;<br>&nbsp; typedef itk::ImageRegionIterator&lt; MatrixImageType &gt; OutputIteratorType;<br>&nbsp; typedef itk::SymmetricEigenAnalysis&lt; MatrixType, VectorType, MatrixType &gt; EigenVectorAnalysisType;<br>&nbsp; typedef MatrixImageType::Pointer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MatrixImagePointer;<br>&nbsp; typedef MatrixImageType::RegionType&nbsp;&nbsp;&nbsp;&nbsp; RegionType;<br>&nbsp; typedef MatrixImageType::PointType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PointType;<br>&nbsp; typedef MatrixImageType::SpacingType&nbsp;&nbsp;&nbsp; SpacingType;<br>&nbsp; typedef itk::ImageRegionIteratorWithIndex&lt;HessianFilterType::OutputImageType&gt;&nbsp; HessianIteratorType;<br>&nbsp; typedef itk::ImageFileWriter&lt; MatrixImageType &gt; MatrixWriterType;<br>&nbsp;<br>int main( int argc, char *argv[] ) <br>{ <br>&nbsp; if( argc &lt; 3 ) <br>&nbsp;&nbsp;&nbsp; { <br>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; &quot;Usage: ./&quot; &lt;&lt; argv[0] &lt;&lt; &quot; inputImage sigma&quot; &lt;&lt; std::endl; <br>&nbsp;&nbsp;&nbsp; } <br>&nbsp;&nbsp; <br>&nbsp; ReaderType::Pointer&nbsp;&nbsp; reader = ReaderType::New(); <br>&nbsp; reader-&gt;SetFileName( argv[1] ); <br>&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp; HessianFilterType::Pointer hessianFilter = HessianFilterType::New(); <br>&nbsp; hessianFilter-&gt;SetInput( reader-&gt;GetOutput() ); <br>&nbsp; if( argc &gt;= 3 ) <br>&nbsp;&nbsp;&nbsp; hessianFilter-&gt;SetSigma( static_cast&lt; double &gt;( atof(argv[2])) ); <br>&nbsp; std::cout &lt;&lt; &quot;Calculating Hessian matrix&quot; &lt;&lt; std::endl; <br>&nbsp; hessianFilter-&gt;Update(); <br>&nbsp; std::cout &lt;&lt; &quot;Done&quot; &lt;&lt; std::endl; <br>&nbsp;&nbsp; <br>&nbsp; EigenVectorAnalysisType&nbsp; evap; <br>&nbsp; HessianFilterType::OutputImageType::Pointer input = hessianFilter-&gt;GetOutput();<br>&nbsp; RegionType region = input-&gt;GetLargestPossibleRegion();<br>&nbsp; SpacingType spacing = input-&gt;GetSpacing();<br>&nbsp; PointType origin = input-&gt;GetOrigin();<br><br>&nbsp; MatrixType eigenMatrix, myMatrix;<br>&nbsp; eigenMatrix[0][0] = 0; eigenMatrix[0][1]=0;eigenMatrix[0][2]=0;<br>&nbsp; eigenMatrix[1][0] = 0; eigenMatrix[1][1]=0;eigenMatrix[1][2]=0;<br>&nbsp; eigenMatrix[2][0] = 0; eigenMatrix[2][1]=0;eigenMatrix[2][2]=0;<br><br>&nbsp; // Allocate the output image<br>&nbsp; MatrixImagePointer m_Output = MatrixImageType::New();<br>&nbsp; m_Output-&gt;SetRegions( region );<br>&nbsp; m_Output-&gt;SetOrigin( origin );<br>&nbsp; m_Output-&gt;SetSpacing( spacing );<br>&nbsp; m_Output-&gt;Allocate();<br>&nbsp; m_Output-&gt;FillBuffer( eigenMatrix );<br><br>&nbsp; VectorType eigenVal;<br>&nbsp; eigenVal[0]=eigenVal[1]=eigenVal[2]=0;<br>&nbsp; HessianIteratorType mIt( input, region );<br>&nbsp; OutputIteratorType oIt( m_Output, region );<br>&nbsp; itk::SymmetricSecondRankTensor&lt;double, 3&gt; myTensor;<br>&nbsp; mIt.GoToBegin();<br>&nbsp; oIt.GoToBegin();<br>&nbsp; while( !mIt.IsAtEnd() )<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Compute eigen values and eigen matrix<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; evap.SetOrderEigenValues( 1 );<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myTensor = mIt.Get();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myMatrix[0][0] = myTensor[0];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myMatrix[0][1] = myTensor[1];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myMatrix[0][2] = myTensor[2];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myMatrix[1][0] = myTensor[1];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myMatrix[1][1] = myTensor[3];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myMatrix[1][2] = myTensor[4];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myMatrix[2][0] = myTensor[2];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myMatrix[2][1] = myTensor[4];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; myMatrix[2][2] = myTensor[5];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; &quot;myTensor &quot; &lt;&lt; myTensor &lt;&lt; std::endl;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; &quot;myMatrix &quot; &lt;&lt; myMatrix &lt;&lt; std::endl;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; &quot;eigenVal &quot; &lt;&lt; eigenVal &lt;&lt; std::endl;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; &quot;eigenMatrix &quot; &lt;&lt; eigenMatrix &lt;&lt; std::endl;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; evap.ComputeEigenValuesAndVectors( myMatrix, eigenVal, eigenMatrix );<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; &quot; After ComputeEigenValuesAndVectors&quot; &lt;&lt; std::endl; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; oIt.Set( eigenMatrix );<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ++oIt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ++mIt;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; MatrixWriterType::Pointer&nbsp;&nbsp; writer = MatrixWriterType::New(); <br>&nbsp; writer-&gt;SetInput( m_Output );<br>&nbsp; writer-&gt;SetFileName( &quot;EigenMatrix.mhd&quot; );&nbsp; <br>&nbsp; try<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp; writer-&gt;Update();<br>&nbsp; }<br>&nbsp; catch ( itk::ExceptionObject e )<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; &quot;Error: &quot; &lt;&lt; e &lt;&lt; std::endl;<br>&nbsp; }<br>&nbsp; return EXIT_SUCCESS; <br>} <br>***************************************************************************************************<o:p></o:p></p></div></body></html>