[ITK] [ITK-users] extracting each component of the GradientRecursiveGaussianImageFilter

Pol Monsó Purtí lluna.nova at gmail.com
Fri Apr 17 12:49:44 EDT 2015


Until somebody can explain why the output of the aforementioned filter has
the same values on each component, here's how to get the gradient on each
dimension:

//features

  typedef itk::RecursiveGaussianImageFilter< TImageType,
GradientImageType > GradientFilterType;

  typename GradientFilterType::Pointer gradientFilter =
GradientFilterType::New();

  gradientFilter->SetInput(imageROIextractor->GetOutput());

  float sigma = 3.5;

  gradientFilter->SetSigma( sigma );

  gradientFilter->SetFirstOrder();

  std::vector< typename GradientImageType::Pointer >
gradients(TImageType::ImageDimension);


  try {

    for(unsigned int dim = 0; dim < TImageType::ImageDimension; dim++) {

      gradientFilter->SetDirection(dim);

      gradientFilter->Update();

      gradients[dim] = gradientFilter->GetOutput();

      gradients[dim]->DisconnectPipeline();

    }

  } catch( itk::ExceptionObject & error ) {

    std::cerr << __FILE__ << ":" << __LINE__ << " Error: " << error <<
std::endl;

    return FUCKEDUP;

  }



2015-04-17 16:01 GMT+02:00 Pol Monsó Purtí <lluna.nova at gmail.com>:

> Apparently, even if the default is a covariantVector of dimension
> ImageDimension (3), the three components of each "pixel" have the same
> value. So the question is still there, how do I retrieve the gradient on
> each dimension of an image?
>
> 2015-04-16 15:30 GMT+02:00 Pol Monsó Purtí <lluna.nova at gmail.com>:
>
>> Hello all,
>>
>> The declaration of thefilter is
>>
>> template<typename TInputImage, typename TOutputImage = Image<
>> CovariantVector< typename NumericTraits< typename TInputImage::PixelType
>> >::RealType, TInputImage::ImageDimension >, TInputImage::ImageDimension >>
>>
>> In my case, ImageDimension = 3
>>
>> So I have two questions.
>>
>> Question number 1:
>> Does the output image hold, for each pixel, the three derivatives? Can
>> they be accessed by
>>
>> it.Get()[0] it.Get()[1] it.Get()[2]
>>
>> where it is itk::ImageRegionIterator< GradientImageType > it(
>> gradientImage,
>> gradientImage->GetRequestedRegion() );
>>
>> ?
>>
>> Question number 2: (just for curiosity)
>> what happens when TOutputImage = Image< PixelType, Dimension> ?
>> and what happens when you create a writer with the default TOutputImage and
>> write to disk? Do the derivatives end in different channels or a magnitude
>> is computed?
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20150417/769c3e6f/attachment-0001.html>
-------------- next part --------------
_____________________________________
Powered by 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.php

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://public.kitware.com/mailman/listinfo/insight-users


More information about the Community mailing list