[Insight-users] Filtering a tensor component accessed
withNthElementImageAdaptor
Vicente Grau
vicente at robots.ox.ac.uk
Tue May 9 03:50:27 EDT 2006
Jim,
I have made the changes in itkImageBase.txx, and the results are what you
expected. The Print() output did not change, but the GetSpacing() result is
now
m_ComponentFilter->GetOutput()->GetSpacing(): [2, 2, 2]
m_ImageAdaptor->GetSpacing(): [2, 2, 2]
Do you want me to file a bug report?
Thanks again for your help.
Vicente
On 08/05/06, Miller, James V (GE, Research) <millerjv at crd.ge.com> wrote:
>
> That is what I feared. ImageAdaptor::SetSpacing() merely delegates down
> to the adapted image. So somewhere in the base class, the ivar m_Spacing is
> being accessed directly.
>
> Can you run another experiment for me?
>
> Edit Insight/Code/Common/itkImageBase.txx. On line 239, could you change
> the line from
>
> m_Spacing = imgData->m_Spacing;
>
> to
>
> m_Spacing = imgData->GetSpacing();
>
> and see if this fixes the issue with the output spacing of the component
> filter? (This will not affect the Print of the Adaptor).
>
> If this works, then we'll need to patch ImageAdaptor so that spacing ivars
> in ImageAdaptor are kept up to date. We'll also consider changing the
> itkImageBase::CopyInformation() to call GetSpacing()/GetOrigin() instead of
> accessing them directly.
>
> Jim
>
> -----Original Message-----
> *From:* insight-users-bounces+millerjv=crd.ge.com at itk.org [mailto:
> insight-users-bounces+millerjv=crd.ge.com at itk.org]*On Behalf Of *Vicente
> Grau
> *Sent:* Monday, May 08, 2006 5:39 AM
> *To:* Jim Miller; insight-users at itk.org
> *Subject:* Re: [Insight-users] Filtering a tensor component accessed
> withNthElementImageAdaptor
>
> 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/20060509/54549136/attachment-0001.htm
More information about the Insight-users
mailing list