[Insight-developers] Image Derivatives - physical vs. index space

Luis Ibanez luis.ibanez at kitware.com
Thu Jul 2 19:47:41 EDT 2009


On Thu, Jul 2, 2009 at 6:01 PM, Samuel Gerber <sgerber at cs.utah.edu> wrote:

> Samuel Gerber wrote:
>
>> Hi Luis
>> <http://public.kitware.com/Bug/my_view_page.php>
>>
>>> The fix will come down to calling the image method:
>>>
>>>  inputImage->RotateArrayByDirectionCosines( gradient, rotatedGradient );
>>>
>>> after every computation of a derivative vector.
>>>
>> I would assume, since the derivative is axis aligned in index space, it
>> could be simplified by only multiplying with the row corresponding to the
>> SetDirection setting in the itkDerivativeImageFilter.
>>
> -------------------------


I believe that this is what the RotatArrayByDirectionCosines() method
does internally, but of course, there is noting better than looking at
the source code   :-)


BTW. This method was later renamed as

    TransformLocalVectorToPhysicalVector()

You will find it in

     Insight/Code/Common/itkImageBase.txx

in lines 498-524:


  template<class TCoordRep>
  void TransformLocalVectorToPhysicalVector(
    const FixedArray<TCoordRep, VImageDimension> & inputGradient,
          FixedArray<TCoordRep, VImageDimension> & outputGradient ) const
    {
    //
    // This temporary implementation should be replaced with Template
MetaProgramming.
    //
#ifdef ITK_USE_ORIENTED_IMAGE_DIRECTION
    const DirectionType & direction = this->GetDirection();
    for (unsigned int i = 0; i < VImageDimension; i++)
      {
      typedef typename NumericTraits<TCoordRep>::AccumulateType
CoordSumType;
      CoordSumType sum = NumericTraits<CoordSumType>::Zero;
      for (unsigned int j = 0; j < VImageDimension; j++)
        {
        sum += direction[i][j] * inputGradient[j];
        }
      outputGradient[i] = static_cast<TCoordRep>( sum );
      }
#else
    for (unsigned int i = 0; i < VImageDimension; i++)
      {
      outputGradient[i] = inputGradient[i];
      }
#endif
    }




I would discourage exposing the computation, since then we will end
up with repeated implementations of the code in multiple locations.


In other words, you shouldn't need to worry about how the gradient
vector is rotated. (unless we suspect of a bug in that code....)



      Regards,


                Luis


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

>
>>
>>  In the meantime,
>>> Could you use the itkGradientImageFilter, instead
>>> of the DerivativesImageFilter for your application ?
>>>
>> Yes I can use the gradient filter instead.
>>
>>
>> Thanks
>> Sam
>>
>>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.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-developers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20090702/9352bc20/attachment.htm>


More information about the Insight-developers mailing list