<br>Hi Kana,<br><br>I may help to consider that the Derivative operator<br>is a centered one.<br><br>Therefore, <br><br>A) When computed First order, <br>     it uses coefficients<br><br>          -0.5,  0.0,   0.5<br><br>
B) When computed Second order, <br>
     it uses coefficients<br>
<br>
          1.0, -2.0, 1.0<br>
<br><br>  Best,<br><br><br>      Luis<br>
<br><br>------------------------------------------------------------<br><div class="gmail_quote">On Mon, Oct 18, 2010 at 11:31 AM, Arunachalam Kana <span dir="ltr">&lt;<a href="mailto:Kana.Arunachalam@fh-wels.at">Kana.Arunachalam@fh-wels.at</a>&gt;</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><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-GB">Hi ITK Team and Luis,</span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-GB"> </span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-GB">To Luis: I am sorry to send a
reply directly to your email instead of <a href="mailto:insight-user@itk.org" target="_blank">insight-user@itk.org</a>.
</span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-GB"> </span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-GB">Your explanation for
derivative calculation was clear. </span></p>

<p><span lang="EN-GB">Gray value at index [8,31,11] = 16951</span></p><div class="im">

<p><span lang="EN-GB">Gray value at index [9,31,11] =
20850</span></p>

<p><span lang="EN-GB">Gray value at index [10,31,11] =
22923</span></p>

<p><span lang="EN-GB">Gray value at index [11,31,11] =
22923</span></p>

</div><p><span lang="EN-GB">Gray value at index [12,31,11] =
20850</span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-GB"> </span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-GB">My next step was to check whether there Is
any difference in calculating second order derivative using below 2 methods:</span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-GB"><span>1.<span style="font: 7pt &quot;Times New Roman&quot;;">      
</span></span></span><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-GB">Using  itkDerivativeImagefilter
: set order=2; direction=0;  code below</span></p>

<p style="text-indent: 17.85pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB">DerivativeFilterType::Pointer
DXXfilter = DerivativeFilterType::New();</span></p>

<p style="text-indent: 17.85pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB">DXXfilter-&gt;SetInput(inputimage);</span></p>

<p style="text-indent: 17.85pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB">DXXfilter-&gt;SetDirection(0);</span></p>

<p style="text-indent: 17.85pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB">DXXfilter-&gt;SetOrder(2);</span></p>

<p style="text-indent: 17.85pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB">DXXfilter-&gt;Update();</span></p>

<p style="text-indent: 17.85pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB"> </span></p>

<p style="text-indent: 17.85pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB">DXX value at [10,31, 11] =
-1036.5</span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-GB"><span>2.<span style="font: 7pt &quot;Times New Roman&quot;;">      
</span></span></span><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-GB">Using
itkDerivativeImagefilter and apply filter 2 time in same direction. Code below</span></p><div class="im">

<p><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB">DerivativeFilterType::Pointer DXfilter =
DerivativeFilterType::New();</span></p>

<p><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB">DXfilter-&gt;SetInput(inputimage);</span></p>

<p><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB">DXfilter-&gt;SetDirection(0);</span></p>

<p><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB">DXfilter-&gt;SetOrder(1);</span></p>

<p><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB">DXfilter-&gt;Update();</span><span lang="EN-GB"></span></p>

</div><p style="text-indent: 35.4pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB">DerivativeFilterType::Pointer
DXXfilter = DerivativeFilterType::New();</span></p>

<p style="text-indent: 35.4pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB">DXXfilter -&gt;SetInput(DXfilter-&gt;GetOutput());</span></p>

<p style="text-indent: 35.4pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB">DXXfilter -&gt;SetDirection(0);</span></p>

<p style="text-indent: 35.4pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB">DXXfilter -&gt;SetOrder(1);</span></p>

<p style="text-indent: 35.4pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB">DXXfilter -&gt;Update();</span><span lang="EN-GB"></span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-GB"> </span></p>

<p style="text-indent: 17.85pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB">DXX value at [10,31, 11] = -502.813
(value is correct as per formula given by Luis in email below)</span></p>

<p style="text-indent: 17.85pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB"> </span></p>

<p style="text-indent: 17.85pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB">After seeing the result i am
bit confused. Why is there a difference in values between two methods?</span></p>

<p style="text-indent: 17.85pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB"> </span></p>

<p style="text-indent: 17.85pt;"><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB">Thank you,</span></p><div class="im">

<p><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB">Regards,</span></p>

<p><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB">Kana </span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-GB"> </span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);" lang="EN-GB"> </span></p>

<div style="border-width: 1pt medium medium; border-style: solid none none; border-color: rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color; padding: 3pt 0cm 0cm;">

<p><b><span style="font-size: 10pt;" lang="EN-US">From:</span></b><span style="font-size: 10pt;" lang="EN-US"> Luis Ibanez
[mailto:<a href="mailto:luis.ibanez@kitware.com" target="_blank">luis.ibanez@kitware.com</a>] <br>
<b>Sent:</b> 16 October 2010 21:39<br>
<b>To:</b> Arunachalam Kana<br>
<b>Cc:</b> <a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a><br>
<b>Subject:</b> Re: [Insight-users] Doubt in derivative calculation using
itkDerivativeImageFilter</span></p>

</div>

<p> </p>

</div><p>Hi Kana,</p><div><div></div><div class="h5"><br>
<br>
It looks like you are not taking the spacing <br>
of the image into account when you compute<br>
the derivatives manually.<br>
<br>
The manual derivative computation should be:<br>
 <br>
<span lang="EN-GB">   ( 22923 – 20850 ) / (2.0 x spacingAlongX </span>)<br>
<br>
that is:<br>
<br>
      f( i+1) - f( i- 1 )  / ( 2 Dx )<br>
<br>
So, I would guess that you image as an<br>
spacing along X that is equal to:   2.0.<br>
<br>
<br>
      Regards,<br>
<br>
<br>
             Luis<br>
<br>
<br>
------------------------------------------------------------</div></div><div><div></div><div class="h5">

<div>

<p>On Fri, Oct 15, 2010 at 9:51 AM, Arunachalam Kana
&lt;<a href="mailto:Kana.Arunachalam@fh-wels.at" target="_blank">Kana.Arunachalam@fh-wels.at</a>&gt;
wrote:</p>

<div>

<div>

<p>Dear ITK Users,</p>

<p> </p>

<p><span lang="EN-GB">I have a small doubt while I
compare the itkDerivativeImageFilter result with manually calculated
derivative. The code below for itkDerivativeImageFilter:</span></p>

<p><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: blue;" lang="EN-GB">typedef</span><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB">
itk::DerivativeImageFilter&lt;CastImageType,CastImageType&gt;
DerivativeFilterType;</span></p>

<p><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;" lang="EN-GB"> </span></p>

<p><span style="font-size: 10pt; font-family: &quot;Courier New&quot;; color: green;" lang="EN-GB">//create First derivative in X direction</span></p>

<p><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">DerivativeFilterType::Pointer
DXfilter = DerivativeFilterType::New();</span></p>

<p><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">DXfilter-&gt;SetInput(inputimage);</span></p>

<p><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">DXfilter-&gt;SetDirection(0);</span></p>

<p><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">DXfilter-&gt;SetOrder(1);</span></p>

<p><span style="font-size: 10pt; font-family: &quot;Courier New&quot;;">DXfilter-&gt;Update();</span></p>

<p><span lang="EN-GB"> </span></p>

<p><span lang="EN-GB">The following are the grayvalue
of indics:</span></p>

<p><span lang="EN-GB">Gray value at index [9,31,11] =
20850</span></p>

<p><span lang="EN-GB">Gray value at index [10,31,11] =
22923</span></p>

<p><span lang="EN-GB">Gray value at index [11,31,11] =
22923</span></p>

<p><span lang="EN-GB"> </span></p>

<p><span lang="EN-GB">Manual calculation of DX at index
[10,31,11]  = 22923 – 20850 = 2073</span></p>

<p><span lang="EN-GB">The filter calculation of DX at
index [10,31,11]  = 518.25 </span></p>

<p><span lang="EN-GB"> </span></p>

<p><span lang="EN-GB">I have a doubt in how the filter
calculates the derivative. When I read the manual it said  “A derivative
at pixel index i = ( j,k), for example, is taken as a weighted</span></p>

<p><span lang="EN-GB">difference of the values at (
j+1,k) and ( j</span><span lang="EN-US">−</span><span lang="EN-GB">1,k).” . I would
like to know how is the weighted difference of the values is calculated and is
it ok to calculated the weighted difference ?</span></p>

<p><span lang="EN-GB"> </span></p>

<p><span lang="EN-GB">Thank you,</span></p>

<p><span lang="EN-GB"> </span></p>

<p><span lang="EN-GB">Regards,</span></p>

<p><span lang="EN-GB">Kana Arunachalam Kannappan</span></p>

<p>Research Associate</p>

<p>FH OÖ Forschungs &amp; Entwicklungs GmbH</p>

<p>Stelzhamer Strasse 23,</p>

<p>4600 Wels,</p>

<p>Austria.</p>

<p>Phone: +43 (0)7242 72811 -4420</p>

<p><a href="mailto:kana.arunachalam@fh-wels.at" target="_blank">kana.arunachalam@fh-wels.at</a></p>

<p><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> </p>

</div>

</div>

<p><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></p>

</div>

<p> </p>

</div></div></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>