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-&gt;SetSpacing(
reader-&gt;GetOutput()-&gt;GetSpacing() ) as a workaround, but it
doesn't seem to affect the stored spacing.<br>
<br>
NthElementImageAdaptor (016AA350)<br>
&nbsp; RTTI typeinfo:&nbsp;&nbsp; class
itk::NthElementImageAdaptor&lt;class itk::Image&lt;class
itk::SymmetricSecondRankTensor&lt;double,3&gt;,3&gt;,double&gt;<br>
&nbsp; Reference Count: 2<br>
&nbsp; Modified Time: 147<br>
&nbsp; Debug: Off<br>
&nbsp; Observers:<br>
&nbsp;&nbsp;&nbsp; none<br>
&nbsp; Source: (none)<br>
&nbsp; Source output index:&nbsp; 0<br>
&nbsp; Release Data: Off<br>
&nbsp; Data Released: False<br>
&nbsp; Global Release Data: Off<br>
&nbsp; PipelineMTime: 0<br>
&nbsp; UpdateMTime: 0<br>
&nbsp; LargestPossibleRegion:<br>
&nbsp;&nbsp;&nbsp; Dimension: 3<br>
&nbsp;&nbsp;&nbsp; Index: [0, 0, 0]<br>
&nbsp;&nbsp;&nbsp; Size: [0, 0, 0]<br>
&nbsp; BufferedRegion:<br>
&nbsp;&nbsp;&nbsp; Dimension: 3<br>
&nbsp;&nbsp;&nbsp; Index: [0, 0, 0]<br>
&nbsp;&nbsp;&nbsp; Size: [20, 20, 20]<br>
&nbsp; RequestedRegion:<br>
&nbsp;&nbsp;&nbsp; Dimension: 3<br>
&nbsp;&nbsp;&nbsp; Index: [0, 0, 0]<br>
&nbsp;&nbsp;&nbsp; Size: [20, 20, 20]<br>
&nbsp; Spacing: [1, 1, 1]<br>
&nbsp; Origin: [0, 0, 0]<br>
&nbsp; 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> &lt;<a href="mailto:millerjv@gmail.com">millerjv@gmail.com</a>&gt; 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-&gt;Print(std::cout);<br><br>I'd
like to see what the spacing is that gets printed here.&nbsp; Perhaps
the adaptor has a different spacing stored than the image it is
adapting.&nbsp; The call to GetSpacing() delegates to the adapted
image.&nbsp; 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> &lt;<a href="mailto:vgrauc@googlemail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">vgrauc@googlemail.com</a>&gt; 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-&gt;GetSpacing(): [2, 2, 2]<br>
m_ComponentFilter-&gt;GetOutput()-&gt;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 &quot;itkSymmetricSecondRankTensor.h&quot;<br>
#include &quot;itkImage.h&quot;<br>
#include &quot;itkImageFileReader.h&quot;<br>
#include &quot;itkRecursiveGaussianImageFilter.h&quot;<br>
#include &quot;itkNthElementImageAdaptor.h&quot;<br>
<br>
<br>
<br>
int main( int argc, char *argv[] )<br>
{<br>
&nbsp;&nbsp;&nbsp; const&nbsp;&nbsp;&nbsp;&nbsp; unsigned
int&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Dimension&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 3;<br>
&nbsp;&nbsp;&nbsp; typedef&nbsp;&nbsp;
double&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
InputPixelType;<br>
<br>
&nbsp;&nbsp;&nbsp; typedef itk::Image&lt;
itk::SymmetricSecondRankTensor&lt; InputPixelType, Dimension &gt; ,
Dimension &gt; InputImageType;<br>
&nbsp;&nbsp;&nbsp; typedef itk::Image&lt; InputPixelType, Dimension &gt;&nbsp;&nbsp; OutputImageType;<br>
&nbsp; <br>
&nbsp;&nbsp;&nbsp; typedef&nbsp;&nbsp; itk::ImageFileReader&lt; InputImageType &gt;&nbsp; ReaderType;<br>
&nbsp;&nbsp;&nbsp; ReaderType::Pointer&nbsp;&nbsp; reader = ReaderType::New();&nbsp; <br>
&nbsp;&nbsp; reader-&gt;SetFileName( argv[1] );<br>
<br>
&nbsp;&nbsp;&nbsp; typedef itk::NthElementImageAdaptor&lt; InputImageType, InputPixelType &gt;&nbsp; OutputImageAdaptorType;<br>
&nbsp;&nbsp;&nbsp; OutputImageAdaptorType::Pointer&nbsp; m_ImageAdaptor = OutputImageAdaptorType::New();&nbsp; <br>
&nbsp;&nbsp;&nbsp; m_ImageAdaptor-&gt;SetImage( reader-&gt;GetOutput() );<br>
&nbsp;&nbsp;&nbsp; m_ImageAdaptor-&gt;Allocate();<br>
&nbsp;&nbsp;&nbsp; m_ImageAdaptor-&gt;SelectNthElement( 0 );<br>
<br>
&nbsp;&nbsp;&nbsp; typedef itk::RecursiveGaussianImageFilter&lt;
OutputImageAdaptorType, OutputImageType &gt;&nbsp;&nbsp;&nbsp;
ComponentFilterType;<br>
&nbsp;&nbsp;&nbsp; ComponentFilterType::Pointer m_ComponentFilter&nbsp; = ComponentFilterType::New();<br>
&nbsp;&nbsp;&nbsp; m_ComponentFilter-&gt;SetInput( m_ImageAdaptor );<br>
<br>
&nbsp;&nbsp;&nbsp; m_ComponentFilter-&gt;Update();<br>
<br>
&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; &quot;m_ImageAdaptor-&gt;GetSpacing():
&quot; &lt;&lt; m_ImageAdaptor-&gt;GetSpacing() &lt;&lt; std::endl;<br>
&nbsp;&nbsp;&nbsp; std::cout &lt;&lt; &quot;m_ComponentFilter-&gt;GetOutput()-&gt;GetSpacing(): &quot; &lt;&lt; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp; m_ComponentFilter-&gt;GetOutput()-&gt;GetSpacing()
&lt;&lt; std::endl;<br>
<br>
&nbsp; 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