<br>Hi Arunachalam,<br><br>The Matrix of EigenVectors is exactly the rotation matrix<br>that you need to apply in order to align with the main <br>directions of the Hessian.<br><br>You can use that matrix to initialize a Versor, by taking <br>
advantage of the versor method "Set( Matrix & )", as <br><br>described in:<br><a href="http://www.itk.org/Doxygen312/html/classitk_1_1Versor.html#d22261bee493be34f2fc3941d24604dc">http://www.itk.org/Doxygen312/html/classitk_1_1Versor.html#d22261bee493be34f2fc3941d24604dc</a><br>
<br> Regards,<br><br> Luis<br><br><br>-----------------------------------------------------------------------<br><div class="gmail_quote">On Thu, Sep 2, 2010 at 7:16 AM, Arunachalam Kana <span dir="ltr"><<a href="mailto:Kana.Arunachalam@fh-wels.at">Kana.Arunachalam@fh-wels.at</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div link="blue" vlink="purple" lang="DE-AT">
<div>
<p class="MsoNormal">Hi itkusers,</p>
<p class="MsoNormal"> </p>
<p class="MsoNormal"><span lang="EN-GB">I have cylinder which can be oriented in any
angle in 3D space. I calculate the direction of cylinder using hessian and
eigen value analysis.</span></p>
<p class="MsoNormal"><span lang="EN-GB">My goal is to draw the intensity profile of
the plane perpendicular to the cylinder direction. The size of the plane is 30
x 30 with the current</span></p>
<p class="MsoNormal"><span lang="EN-GB">Point (point for which the hessian is
calculate) as center. </span></p>
<p class="MsoNormal"><span lang="EN-GB"> </span></p>
<p class="MsoNormal"><span lang="EN-GB">My pipeline is as follows: Read image ->
cast image to float -> calculate second derivatives ->create hessian
matrix ->calculate eigen values and vector.</span></p>
<p class="MsoNormal"><span lang="EN-GB"> </span></p>
<p class="MsoNormal"><span lang="EN-GB">So now i have one vector showing the
direction of cylinder (called normal) and the other two orthogonal to it
(called ortho_1 and ortho_2). Till this point </span></p>
<p class="MsoNormal"><span lang="EN-GB">I am clear. </span></p>
<p class="MsoNormal"><span lang="EN-GB">As my goal is to extract the plane which is
formed by ortho_1 and ortho_2 and of size 30x30, i decided to do the following:</span></p>
<p><span lang="EN-GB"><span>1.<span style="font: 7pt "Times New Roman";">
</span></span></span><span lang="EN-GB">to align the plane create by
ortho_1 and ortho_2 parallel to z axis - rotate the image using versor
transform and align to z direction. I referred to versorrigidtransform example
in itkguide.</span></p>
<p><span lang="EN-GB"><span>2.<span style="font: 7pt "Times New Roman";">
</span></span></span><span lang="EN-GB">Translate the point to be in
first slice.</span></p>
<p><span lang="EN-GB"><span>3.<span style="font: 7pt "Times New Roman";">
</span></span></span><span lang="EN-GB">Select a region in the first
slice and write the gray values as csv. </span></p>
<p class="MsoNormal"><span lang="EN-GB"> </span></p>
<p class="MsoNormal"><span lang="EN-GB">I am stuck in rotation step. My rotation is
not performing as expected. I think something is missing, don’t know
where or what ? I have pasted my code below.</span></p>
<p class="MsoNormal"><span lang="EN-GB">If anyone thinks that this idea is a over
kill for my goal, other ideas is also welcomed.</span></p>
<p class="MsoNormal"><span lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: blue;" lang="EN-GB">int</span><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> main(<span style="color: blue;">int</span> argc, <span style="color: blue;">char</span>* argv
[] )</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB">{</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: green;">//image input filenames</span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: blue;">const</span> <span style="color: blue;">char</span> *
inputFilename = <span style="color: rgb(163, 21, 21);">"C:/LIBS/SW_Development/GradientAnalysis/testdata/itkVirtual-SingleFibresInXY-r3.mhd"</span>;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: green;">//declare pixeltype and dimension</span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: blue;">typedef</span> <span style="color: blue;">double</span>
InputPixelType;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: blue;">typedef</span> <span style="color: blue;">float</span>
CastPixelType;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: blue;">typedef</span> <span style="color: blue;">int</span>
CCPixelType;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;">typedef</span><span style="font-size: 10pt; font-family: "Courier New";">
itk::SymmetricSecondRankTensor< <span style="color: blue;">float</span>,
Dimension > T_PixelType;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> <span style="color: blue;">typedef</span>
itk::Vector< VectorPixelType, Dimension > EV_PixelType;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> <span style="color: green;">//declare image type</span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> <span style="color: blue;">typedef</span>
itk::Image< InputPixelType, Dimension > InputImageType;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> <span style="color: blue;">typedef</span>
itk::Image< CastPixelType, Dimension > CastImageType;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> </span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;" lang="EN-GB">typedef</span><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> itk::Image<
CCPixelType, Dimension > CCImageType;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: blue;">typedef</span> CCImageType::IndexType CCIndexType;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: green;">//set image reader filter parameters</span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: blue;">typedef</span> itk::ImageFileReader< InputImageType
> ReaderType;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> ReaderType::Pointer
reader_1 = ReaderType::New();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> reader_1->SetFileName(
inputFilename );</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> reader_1->Update();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: green;">//set cast filter parameters to int as the derivative can
be positive and negative</span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: blue;">typedef</span> itk::CastImageFilter< InputImageType,
CastImageType > CastType;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> CastType::Pointer
castfilter = CastType::New();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> castfilter->SetInput(
reader_1->GetOutput() ); </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> castfilter->Update();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: green;">//create derivative</span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: blue;">typedef</span>
itk::DerivativeImageFilter<CastImageType,CastImageType>
DerivativeFilterType;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: green;">//create First derivative in X direction</span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DerivativeFilterType::Pointer
DXfilter = DerivativeFilterType::New();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DXfilter->SetInput(castfilter->GetOutput());</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DXfilter->SetDirection(0);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DXfilter->SetOrder(1);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DXfilter->Update();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: green;">//create second derivative in XX direction</span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DerivativeFilterType::Pointer
DXXfilter = DerivativeFilterType::New();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DXXfilter->SetInput(DXfilter->GetOutput());</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DXXfilter->SetDirection(0);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DXXfilter->SetOrder(1);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DXXfilter->Update();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: green;">//create second derivative in XY direction</span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DerivativeFilterType::Pointer
DXYfilter = DerivativeFilterType::New();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DXYfilter->SetInput(DXfilter->GetOutput());</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DXYfilter->SetDirection(1);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DXYfilter->SetOrder(1);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DXYfilter->Update();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: green;">//create second derivative in XZ direction</span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DerivativeFilterType::Pointer
DXZfilter = DerivativeFilterType::New();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DXZfilter->SetInput(DXfilter->GetOutput());</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DXZfilter->SetDirection(2);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DXZfilter->SetOrder(1);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DXZfilter->Update();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: green;">//create first derivative in Y direction</span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DerivativeFilterType::Pointer
DYfilter = DerivativeFilterType::New();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DYfilter->SetInput(castfilter->GetOutput());</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DYfilter->SetDirection(1);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DYfilter->SetOrder(1);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DYfilter->Update();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: green;">//create second derivative in YY direction</span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DerivativeFilterType::Pointer
DYYfilter = DerivativeFilterType::New();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DYYfilter->SetInput(DYfilter->GetOutput());</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DYYfilter->SetDirection(1);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DYYfilter->SetOrder(1);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DYYfilter->Update();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: green;">//create second derivative in YZ direction</span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DerivativeFilterType::Pointer
DYZfilter = DerivativeFilterType::New();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DYZfilter->SetInput(DYfilter->GetOutput());</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DYZfilter->SetDirection(2);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DYZfilter->SetOrder(1);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DYZfilter->Update();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: green;">//create first derivative in Z direction</span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DerivativeFilterType::Pointer
DZfilter = DerivativeFilterType::New();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DZfilter->SetInput(castfilter->GetOutput());</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DZfilter->SetDirection(2);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DZfilter->SetOrder(1);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DZfilter->Update();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: green;">//create second derivative in ZZ direction</span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DerivativeFilterType::Pointer
DZZfilter = DerivativeFilterType::New();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DZZfilter->SetInput(DZfilter->GetOutput());</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DZZfilter->SetDirection(2);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DZZfilter->SetOrder(1);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DZZfilter->Update();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span><span style="font-size: 10pt; font-family: "Courier New"; color: green;">//set eigen
analysis</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> <span style="color: blue;">typedef</span>
itk::SymmetricEigenAnalysis < T_PixelType, VectorPixelType, EV_PixelType
> EigAnalysisType;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> EigAnalysisType eig;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> eig.SetDimension( Dimension );</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> </span><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB">eig.SetOrderEigenMagnitudes( <span style="color: blue;">true</span> );</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: green;">//derivative image iterator</span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: blue;">typedef</span> itk::ImageRegionIterator
<CastImageType> CastImageIteratorType;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> CastImageIteratorType
DXXIter(DXXfilter->GetOutput(),
DXXfilter->GetOutput()->GetLargestPossibleRegion());</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> CastImageIteratorType
DXYIter(DXYfilter->GetOutput(),
DXYfilter->GetOutput()->GetLargestPossibleRegion());</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> CastImageIteratorType
DXZIter(DXZfilter->GetOutput(),
DXZfilter->GetOutput()->GetLargestPossibleRegion());</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> CastImageIteratorType
DYYIter(DYYfilter->GetOutput(),
DYYfilter->GetOutput()->GetLargestPossibleRegion());</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> CastImageIteratorType
DYZIter(DYZfilter->GetOutput(),
DYZfilter->GetOutput()->GetLargestPossibleRegion());</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> CastImageIteratorType
DZZIter(DZZfilter->GetOutput(), DZZfilter->GetOutput()->GetLargestPossibleRegion());</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> CastImageIteratorType
InIter(castfilter->GetOutput(),
castfilter->GetOutput()->GetLargestPossibleRegion());</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> std::multimap<CCPixelType,CCIndexType>::iterator
it;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: blue;">typedef</span>
itk::ResampleImageFilter<CastImageType,CastImageType> ResampleFilterType;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> ResampleFilterType::Pointer
rfilter = ResampleFilterType::New();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style="text-indent: 35.4pt;"><span style="font-size: 10pt; font-family: "Courier New"; color: blue;" lang="EN-GB">InIter.GoToBegin();</span><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"></span></p>
<p class="MsoNormal" style="text-indent: 35.4pt;"><span style="font-size: 10pt; font-family: "Courier New"; color: blue;" lang="EN-GB">While (
!InIter.IsAtEnd() )</span><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> {</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> IndexType
currentindex = InIter.GetIndex();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: green;">//initialise the variables</span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> T_PixelType
hess_matrix;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> VectorPixelType
eigen_values;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> EV_PixelType
eigen_vectors;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: green;">//set index for various iterators</span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DXXIter.SetIndex(currentindex);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DXYIter.SetIndex(currentindex);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DXZIter.SetIndex(currentindex);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DYYIter.SetIndex(currentindex);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DYZIter.SetIndex(currentindex);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> DZZIter.SetIndex(currentindex);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> CCIter.SetIndex(currentindex);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> InIter.SetIndex(currentindex);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: green;">//upload the hessian matrix from different second
derivative</span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> hess_matrix[0]
= DXXIter.Get();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> hess_matrix[1]
= DXYIter.Get();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> hess_matrix[2]
= DXZIter.Get();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> hess_matrix[3]
= DYYIter.Get();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> hess_matrix[4]
= DYZIter.Get();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> hess_matrix[5]
= DZZIter.Get();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: green;">//calculate the eigen values of the hessian matrix</span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> eig.ComputeEigenValuesAndVectors(
hess_matrix, eigen_values, eigen_vectors );</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: green;">///get the eigen vectors</span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> VectorPixelType
normal, ortho_1, ortho_2;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> normal =
eigen_vectors[0]; <span style="color: green;">//direction of the fiber</span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> ortho_1 =
eigen_vectors[1]; <span style="color: green;">//one the orthogonal axis</span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> ortho_2 =
eigen_vectors[2]; <span style="color: green;">//other orthogonal axis</span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New"; color: green;" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: blue;">double</span> AdotB = normal[2] ;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: blue;">double</span> ModA_ModB = sqrt(pow(normal[0],2) +
pow(normal[1],2) + pow(normal[2],2));</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: blue;">double</span> theta = acos( AdotB / ModA_ModB ) ;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: blue;">double</span> angle = sin ( theta / 2 );</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: blue;">typedef</span> itk::VersorTransform <<span style="color: blue;">double</span>> TransformType;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> TransformType::Pointer
transform = TransformType::New();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: blue;">typedef</span> TransformType::VersorType VersorType;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: blue;">typedef</span> TransformType::AxisType AxisType;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: blue;">typedef</span> TransformType::CenterType CenterType;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> AxisType
axis;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> axis[0]=
normal[0];</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> axis[1]=
normal[1];</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> axis[2]=
normal[2];</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> VersorType
rotation;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> rotation.Set(axis,
angle);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> transform->SetRotation(rotation);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> CenterType
center;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> center[0]
= normal[0];</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> center[1]
= normal[1];</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> center[2]
= normal[2];</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> transform->SetCenter(center);</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: blue;">typedef</span>
itk::LinearInterpolateImageFunction<CastImageType, <span style="color: blue;">double</span>
> InterpolatorType;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> InterpolatorType::Pointer
interpolator = InterpolatorType::New();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> CastImageType::SizeType
imgSize;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> imgSize =
ccfilter->GetOutput()->GetBufferedRegion().GetSize();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> rfilter->SetTransform(
transform );</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> rfilter->SetInterpolator(
interpolator );</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> rfilter->SetSize(
imgSize );</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> rfilter->SetInput(
castfilter->GetOutput() );</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> rfilter->Update();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> }<span style="color: green;">//if</span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> }</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: green;">//set image writer parameters</span></span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: blue;">const</span> <span style="color: blue;">char</span> *
outputFilename = <span style="color: rgb(163, 21, 21);">"C:/LIBS/SW_Development/GradientAnalysis/testdata/itkVirtual-SingleFibresInXY-r3-MAE-resampletest.mhd"</span>;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: blue;">typedef</span> itk::ImageFileWriter< CastImageType >
WriterType;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> WriterType::Pointer
writer = WriterType::New();</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> writer->SetFileName(
outputFilename );</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> writer->SetInput(rfilter->GetOutput());</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: blue;">try</span> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> { </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> writer->Update();
</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> } </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: blue;">catch</span>( itk::ExceptionObject & err ) </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> { </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> std::cerr
<< <span style="color: rgb(163, 21, 21);">"ExceptionObject caught !"</span>
<< std::endl; </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span><span style="font-size: 10pt; font-family: "Courier New";">std::cerr << err
<< std::endl; </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";"> </span><span style="font-size: 10pt; font-family: "Courier New"; color: blue;" lang="EN-GB">return</span><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> EXIT_FAILURE;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> } </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> </span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB"> <span style="color: blue;">return</span> EXIT_SUCCESS;</span></p>
<p class="MsoNormal" style=""><span style="font-size: 10pt; font-family: "Courier New";" lang="EN-GB">}</span></p>
<p class="MsoNormal"><span lang="EN-GB"> </span></p>
<p class="MsoNormal"><span lang="EN-GB">Any help will be appreciated.</span></p>
<p class="MsoNormal"><span lang="EN-GB"> </span></p>
<p class="MsoNormal"><span lang="EN-GB">Thank you,</span></p>
<p class="MsoNormal"><span lang="EN-GB">Regards,</span></p>
<p class="MsoNormal"><span lang="EN-GB">Kana Arunachalam Kannappan</span></p>
<p class="MsoNormal"><span lang="EN-GB">Research Associate</span></p>
<p class="MsoNormal"><span lang="EN-GB">FH OÖ Forschungs & Entwicklungs GmbH</span></p>
<p class="MsoNormal"><span lang="EN-GB">Stelzhamer Strasse 23,</span></p>
<p class="MsoNormal"><span lang="EN-GB">4600 Wels,</span></p>
<p class="MsoNormal">Austria.</p>
<p class="MsoNormal">Phone: +43 (0)7242 72811 -4420</p>
<p class="MsoNormal"><a href="mailto:kana.arunachalam@fh-wels.at" target="_blank">kana.arunachalam@fh-wels.at</a></p>
<p class="MsoNormal"><a href="http://www.fh-ooe.at" target="_blank">www.fh-ooe.at</a>; <a href="http://www.3dct.at" target="_blank">www.3dct.at</a></p>
<p class="MsoNormal"> </p>
</div>
</div>
<br>_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br>