[ITK-users] extracting each component of the GradientRecursiveGaussianImageFilter

Pol Monsó Purtí lluna.nova at gmail.com
Fri Apr 17 13:36:15 EDT 2015


I see!

Thanks Michka, It's a pity I didn't stumble on your example before!

// Allows to select the X or Y output images
  typedef itk::VectorIndexSelectionCastImageFilter< CovImageType,
DoubleImageType > IndexSelectionType;
  IndexSelectionType::Pointer indexSelectionFilter = IndexSelectionType::New();
  indexSelectionFilter->SetInput( filter->GetOutput() );
    indexSelectionFilter->SetIndex( i );

Thats the key



2015-04-17 19:23 GMT+02:00 <michkapopoff at gmail.com>:

> Hi
>
> I wrote two examples for this filter some time ago:
>
>
> http://itk.org/ITKExamples/src/Filtering/ImageGradient/ApplyGradientRecursiveGaussianImageFilter/Documentation.html
>
> http://itk.org/ITKExamples/src/Filtering/ImageGradient/ApplyGradientRecursiveGaussianImageFilterWithVectorInput/Documentation.html
>
> They were used on 2D images, so I guess extending to 3D should work,
> though I did not test it.
> I used vectorIndexSelectionCastImageFilter to extract the images for each
> component.
>
> A good help is to save the output of the GradientRecursiceGaussianFilter
> to a .mha file, and open if with Paraview.
> There you will see the different components with their names.
>
> If you want the magnitude, there is a VectorMagnitudeImageFilter (see the
> first example).
>
> Hope that helps. I would be interested to know if everything is fine with
> 3D images using this filter; I never found the time
> to test it thoroughly.
>
> Michka
>
>
> On 17 Apr 2015, at 18:49, Pol Monsó Purtí <lluna.nova at gmail.com> wrote:
>
>
> 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?
>>>
>>
>>
> _____________________________________
> 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
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/insight-users/attachments/20150417/e270d79b/attachment.html>


More information about the Insight-users mailing list