[Insight-developers] Image Derivatives - physical vs. index space
sgerber at cs.utah.edu
sgerber at cs.utah.edu
Thu Jul 2 21:41:14 EDT 2009
What I meant is that the output of the itkDerivativeImageFilter is a
scalar image and not a vector image and it seems that calling
TransformLocalVectorToPhysicalVector
would require to package the scalar into a vector which would be a lot
of unnecessary overhead.
Regards
Sam
Quoting Luis Ibanez <luis.ibanez at kitware.com>:
> 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
>>
>
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
More information about the Insight-developers
mailing list