[Insight-users] Doubt in derivative calculation using itkDerivativeImageFilter

Arunachalam Kana Kana.Arunachalam at fh-wels.at
Mon Oct 18 11:31:18 EDT 2010


Hi ITK Team and Luis,



To Luis: I am sorry to send a reply directly to your email instead of insight-user at itk.org<mailto:insight-user at itk.org>.



Your explanation for derivative calculation was clear.

Gray value at index [8,31,11] = 16951

Gray value at index [9,31,11] = 20850

Gray value at index [10,31,11] = 22923

Gray value at index [11,31,11] = 22923

Gray value at index [12,31,11] = 20850



My next step was to check whether there Is any difference in calculating second order derivative using below 2 methods:

1.       Using  itkDerivativeImagefilter : set order=2; direction=0;  code below

DerivativeFilterType::Pointer DXXfilter = DerivativeFilterType::New();

DXXfilter->SetInput(inputimage);

DXXfilter->SetDirection(0);

DXXfilter->SetOrder(2);

DXXfilter->Update();



DXX value at [10,31, 11] = -1036.5

2.       Using itkDerivativeImagefilter and apply filter 2 time in same direction. Code below

DerivativeFilterType::Pointer DXfilter = DerivativeFilterType::New();

DXfilter->SetInput(inputimage);

DXfilter->SetDirection(0);

DXfilter->SetOrder(1);

DXfilter->Update();

DerivativeFilterType::Pointer DXXfilter = DerivativeFilterType::New();

DXXfilter ->SetInput(DXfilter->GetOutput());

DXXfilter ->SetDirection(0);

DXXfilter ->SetOrder(1);

DXXfilter ->Update();



DXX value at [10,31, 11] = -502.813 (value is correct as per formula given by Luis in email below)



After seeing the result i am bit confused. Why is there a difference in values between two methods?



Thank you,

Regards,

Kana





From: Luis Ibanez [mailto:luis.ibanez at kitware.com]
Sent: 16 October 2010 21:39
To: Arunachalam Kana
Cc: insight-users at itk.org
Subject: Re: [Insight-users] Doubt in derivative calculation using itkDerivativeImageFilter



Hi Kana,

It looks like you are not taking the spacing
of the image into account when you compute
the derivatives manually.

The manual derivative computation should be:

   ( 22923 – 20850 ) / (2.0 x spacingAlongX )

that is:

      f( i+1) - f( i- 1 )  / ( 2 Dx )

So, I would guess that you image as an
spacing along X that is equal to:   2.0.


      Regards,


             Luis


------------------------------------------------------------

On Fri, Oct 15, 2010 at 9:51 AM, Arunachalam Kana <Kana.Arunachalam at fh-wels.at<mailto:Kana.Arunachalam at fh-wels.at>> wrote:

Dear ITK Users,



I have a small doubt while I compare the itkDerivativeImageFilter result with manually calculated derivative. The code below for itkDerivativeImageFilter:

typedef itk::DerivativeImageFilter<CastImageType,CastImageType> DerivativeFilterType;



//create First derivative in X direction

DerivativeFilterType::Pointer DXfilter = DerivativeFilterType::New();

DXfilter->SetInput(inputimage);

DXfilter->SetDirection(0);

DXfilter->SetOrder(1);

DXfilter->Update();



The following are the grayvalue of indics:

Gray value at index [9,31,11] = 20850

Gray value at index [10,31,11] = 22923

Gray value at index [11,31,11] = 22923



Manual calculation of DX at index [10,31,11]  = 22923 – 20850 = 2073

The filter calculation of DX at index [10,31,11]  = 518.25



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

difference of the values at ( j+1,k) and ( j−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 ?



Thank you,



Regards,

Kana Arunachalam Kannappan

Research Associate

FH OÖ Forschungs & Entwicklungs GmbH

Stelzhamer Strasse 23,

4600 Wels,

Austria.

Phone: +43 (0)7242 72811 -4420

kana.arunachalam at fh-wels.at<mailto:kana.arunachalam at fh-wels.at>

www.fh-ooe.at<http://www.fh-ooe.at>; www.3dct.at<http://www.3dct.at>



_____________________________________
Powered by www.kitware.com<http://www.kitware.com>

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.html

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.itk.org/mailman/listinfo/insight-users


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20101018/e08bb7a9/attachment.htm>


More information about the Insight-users mailing list