[Insight-users] Filtering a tensor component accessed with NthElementImageAdaptor

Vicente Grau vgrauc at googlemail.com
Mon May 8 05:38:41 EDT 2006


Jim,

thanks for your reply. I have attached the output of the Print() statement
below. As you thought, the spacing stored by the adaptor seems to be
[1,1,1].
I have also tried m_ImageAdaptor->SetSpacing(
reader->GetOutput()->GetSpacing() ) as a workaround, but it doesn't seem to
affect the stored spacing.

NthElementImageAdaptor (016AA350)
  RTTI typeinfo:   class itk::NthElementImageAdaptor<class itk::Image<class
itk::SymmetricSecondRankTensor<double,3>,3>,double>
  Reference Count: 2
  Modified Time: 147
  Debug: Off
  Observers:
    none
  Source: (none)
  Source output index:  0
  Release Data: Off
  Data Released: False
  Global Release Data: Off
  PipelineMTime: 0
  UpdateMTime: 0
  LargestPossibleRegion:
    Dimension: 3
    Index: [0, 0, 0]
    Size: [0, 0, 0]
  BufferedRegion:
    Dimension: 3
    Index: [0, 0, 0]
    Size: [20, 20, 20]
  RequestedRegion:
    Dimension: 3
    Index: [0, 0, 0]
    Size: [20, 20, 20]
  Spacing: [1, 1, 1]
  Origin: [0, 0, 0]
  Direction:
1 0 0
0 1 0
0 0 1

On 05/05/06, Jim Miller <millerjv at gmail.com> wrote:
>
> Vicente,
>
> In your set of print statements, can you do a
>
> m_ImageAdaptor->Print(std::cout);
>
> I'd like to see what the spacing is that gets printed here.  Perhaps the
> adaptor has a different spacing stored than the image it is adapting.  The
> call to GetSpacing() delegates to the adapted image.  But the call to
> Print() will print the ivar of the adaptor not the adapted image.
>
> Jim
>
>
>
>
> On 5/5/06, Vicente Grau <vgrauc at googlemail.com> wrote:
>
> > Dear all,
>
> I am writing a filter to calculate the gradient structure tensor. This
> involves calculating an NxN matrix for each voxel of the image, and then
> applying a gaussian filter to each one of the components of the matrix (
> i.e., taking one component of the matrix at every voxel to create a new
> image, and applying a gaussian filter on this new image). Based on
> HessianRecursiveGausianImageFilter, I am using NthElementImageAdaptor and
> three instances of RecursiveGaussianImageFilter to filter in the x, y and z
> directions. As I saw in previous submissions to the list, I defined the
> first of the gaussian filters to accept the adaptor as an input.
> I have been getting errors in the results (basically, the filters behave
> as if the pixel spacing were always [1 1 1], though it's not), so I wrote
> this very simple piece of code to check that image spacing has the expected
> values. I have attached the code below. It works by reading a tensor image
> from a file, and applying a gaussian filter to the first component of the
> tensor (of course, I would have to define things as filter direction, sigma,
> etc., but here I just wanted to check the spacing). The input image is all
> zeros, though I don't think this matters in this case. With an input image
> with spacing [2 2 2], the program output is:
>
> m_ImageAdaptor->GetSpacing(): [2, 2, 2]
> m_ComponentFilter->GetOutput()->GetSpacing(): [1, 1, 1]
>
> which is exactly the same error I got in my structure tensor calculation
> program. It seems that the output of the filter has a different spacing from
> the input, so when I attach a second filter to the output of the first one,
> the result is wrong. Could anybody tell me what I am doing wrong here?
> Thanks a lot,
>
> Vicente
>
> /**************************** Code follows ***********************/
>
> #include "itkSymmetricSecondRankTensor.h"
> #include "itkImage.h"
> #include "itkImageFileReader.h"
> #include "itkRecursiveGaussianImageFilter.h"
> #include "itkNthElementImageAdaptor.h"
>
>
>
> int main( int argc, char *argv[] )
> {
>     const     unsigned int        Dimension       = 3;
>     typedef   double              InputPixelType;
>
>     typedef itk::Image< itk::SymmetricSecondRankTensor< InputPixelType,
> Dimension > , Dimension > InputImageType;
>     typedef itk::Image< InputPixelType, Dimension >   OutputImageType;
>
>     typedef   itk::ImageFileReader< InputImageType >  ReaderType;
>     ReaderType::Pointer   reader = ReaderType::New();
>    reader->SetFileName( argv[1] );
>
>     typedef itk::NthElementImageAdaptor< InputImageType, InputPixelType >
> OutputImageAdaptorType;
>     OutputImageAdaptorType::Pointer  m_ImageAdaptor =
> OutputImageAdaptorType::New();
>     m_ImageAdaptor->SetImage( reader->GetOutput() );
>     m_ImageAdaptor->Allocate();
>     m_ImageAdaptor->SelectNthElement( 0 );
>
>     typedef itk::RecursiveGaussianImageFilter< OutputImageAdaptorType,
> OutputImageType >    ComponentFilterType;
>     ComponentFilterType::Pointer m_ComponentFilter  =
> ComponentFilterType::New();
>     m_ComponentFilter->SetInput( m_ImageAdaptor );
>
>     m_ComponentFilter->Update();
>
>     std::cout << "m_ImageAdaptor->GetSpacing(): " <<
> m_ImageAdaptor->GetSpacing() << std::endl;
>     std::cout << "m_ComponentFilter->GetOutput()->GetSpacing(): " <<
>
> m_ComponentFilter->GetOutput()->GetSpacing() << std::endl;
>
>   return EXIT_SUCCESS;
> }
>
>
>
>
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>
>
>
>


--
Vicente Grau
Wolfson Medical Vision Laboratory
Department of Engineering Science
University of Oxford
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20060508/7f50ae62/attachment.htm


More information about the Insight-users mailing list