Jim,<br>
<br>
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].<br>
I have also tried m_ImageAdaptor->SetSpacing(
reader->GetOutput()->GetSpacing() ) as a workaround, but it
doesn't seem to affect the stored spacing.<br>
<br>
NthElementImageAdaptor (016AA350)<br>
RTTI typeinfo: class
itk::NthElementImageAdaptor<class itk::Image<class
itk::SymmetricSecondRankTensor<double,3>,3>,double><br>
Reference Count: 2<br>
Modified Time: 147<br>
Debug: Off<br>
Observers:<br>
none<br>
Source: (none)<br>
Source output index: 0<br>
Release Data: Off<br>
Data Released: False<br>
Global Release Data: Off<br>
PipelineMTime: 0<br>
UpdateMTime: 0<br>
LargestPossibleRegion:<br>
Dimension: 3<br>
Index: [0, 0, 0]<br>
Size: [0, 0, 0]<br>
BufferedRegion:<br>
Dimension: 3<br>
Index: [0, 0, 0]<br>
Size: [20, 20, 20]<br>
RequestedRegion:<br>
Dimension: 3<br>
Index: [0, 0, 0]<br>
Size: [20, 20, 20]<br>
Spacing: [1, 1, 1]<br>
Origin: [0, 0, 0]<br>
Direction:<br>
1 0 0<br>
0 1 0<br>
0 0 1<br><br><div><span class="gmail_quote">On 05/05/06, <b class="gmail_sendername">Jim Miller</b> <<a href="mailto:millerjv@gmail.com">millerjv@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style="direction: ltr;"><span id="st" name="st" class="st">Vicente</span>, <br><br>In your set of print statements, can you do a <br><br>m_ImageAdaptor->Print(std::cout);<br><br>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.
<br></div><div style="direction: ltr;"><span class="sg"><br>Jim<br><br><br><br><br></span></div><div style="direction: ltr;"><div></div><div style="direction: ltr;"><span class="e" id="q_10b06462c8f5cce9_3"><span class="gmail_quote">
On 5/5/06, <b class="gmail_sendername">Vicente Grau</b> <<a href="mailto:vgrauc@googlemail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">vgrauc@googlemail.com</a>> wrote:</span></span></div>
<div style="direction: ltr;"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"></blockquote></div><div style="direction: ltr;"><span class="e" id="q_10b06462c8f5cce9_5">
<div style="direction: ltr;">Dear all,<br>
<br>
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.<br>
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:<br>
<br>
m_ImageAdaptor->GetSpacing(): [2, 2, 2]<br>
m_ComponentFilter->GetOutput()->GetSpacing(): [1, 1, 1]<br>
<br>
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,<br>
<br>
Vicente<br>
<br>
/**************************** Code follows ***********************/<br>
<br>
#include "itkSymmetricSecondRankTensor.h"<br>
#include "itkImage.h"<br>
#include "itkImageFileReader.h"<br>
#include "itkRecursiveGaussianImageFilter.h"<br>
#include "itkNthElementImageAdaptor.h"<br>
<br>
<br>
<br>
int main( int argc, char *argv[] )<br>
{<br>
const unsigned
int
Dimension = 3;<br>
typedef
double
InputPixelType;<br>
<br>
typedef itk::Image<
itk::SymmetricSecondRankTensor< InputPixelType, Dimension > ,
Dimension > InputImageType;<br>
typedef itk::Image< InputPixelType, Dimension > OutputImageType;<br>
<br>
typedef itk::ImageFileReader< InputImageType > ReaderType;<br>
ReaderType::Pointer reader = ReaderType::New(); <br>
reader->SetFileName( argv[1] );<br>
<br>
typedef itk::NthElementImageAdaptor< InputImageType, InputPixelType > OutputImageAdaptorType;<br>
OutputImageAdaptorType::Pointer m_ImageAdaptor = OutputImageAdaptorType::New(); <br>
m_ImageAdaptor->SetImage( reader->GetOutput() );<br>
m_ImageAdaptor->Allocate();<br>
m_ImageAdaptor->SelectNthElement( 0 );<br>
<br>
typedef itk::RecursiveGaussianImageFilter<
OutputImageAdaptorType, OutputImageType >
ComponentFilterType;<br>
ComponentFilterType::Pointer m_ComponentFilter = ComponentFilterType::New();<br>
m_ComponentFilter->SetInput( m_ImageAdaptor );<br>
<br>
m_ComponentFilter->Update();<br>
<br>
std::cout << "m_ImageAdaptor->GetSpacing():
" << m_ImageAdaptor->GetSpacing() << std::endl;<br>
std::cout << "m_ComponentFilter->GetOutput()->GetSpacing(): " << <br>
m_ComponentFilter->GetOutput()->GetSpacing()
<< std::endl;<br>
<br>
return EXIT_SUCCESS;<br>
}<br>
<br>
<br>
<br>
<br>
</div><br></span></div><div style="direction: ltr;"><span class="q">_______________________________________________<br>Insight-users mailing list<br><a href="mailto:Insight-users@itk.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
Insight-users@<span id="st" name="st" class="st">itk</span>.org</a><br><a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://www.<span id="st" name="st" class="st">itk</span>.org/mailman/listinfo/insight-users</a><br><br><br></span></div><div style="direction: ltr;"></div><br>
</div></blockquote></div><br><br clear="all"><br>-- <br>Vicente Grau<br>Wolfson Medical Vision Laboratory<br>Department of Engineering Science<br>University of Oxford