Jim,<br>
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<br>
<br>
m_ComponentFilter->GetOutput()->GetSpacing(): [2, 2, 2]<br>
m_ImageAdaptor->GetSpacing(): [2, 2, 2]<br>
<br>
Do you want me to file a bug report?<br>
Thanks again for your help.<br>
<br>
Vicente<br><br><div><span class="gmail_quote">On 08/05/06, <b class="gmail_sendername">Miller, James V (GE, Research)</b> <<a href="mailto:millerjv@crd.ge.com">millerjv@crd.ge.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;">
<div><span><font color="#0000ff" face="Arial" size="2">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.</font></span></div>
<div><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div><span><font color="#0000ff" face="Arial" size="2">Can
you run another experiment for me?</font></span></div>
<div><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div><span><font color="#0000ff" face="Arial" size="2">Edit
Insight/Code/Common/itkImageBase.txx. On line 239, could you change the
line from</font></span></div>
<div><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div><span><font color="#0000ff" face="Arial" size="2"> m_Spacing = imgData->m_Spacing;</font></span></div>
<div><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div><span><font color="#0000ff" face="Arial" size="2">to</font></span></div>
<div><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div><span><font color="#0000ff" face="Arial" size="2">
m_Spacing = imgData->GetSpacing();</font></span></div>
<div><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div><span><font color="#0000ff" face="Arial" size="2">and
see if this fixes the issue with the output spacing of the component filter?
(This will not affect the Print of the Adaptor).</font></span></div>
<div><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div><span><font color="#0000ff" face="Arial" size="2">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.</font></span></div>
<div><span><font color="#0000ff" face="Arial" size="2"></font></span> </div>
<div><span><font color="#0000ff" face="Arial" size="2">Jim</font></span></div>
<blockquote></blockquote></div><div style="direction: ltr;"><span class="e" id="q_10b1471c838759e1_1">
<div align="left" dir="ltr"><font face="Tahoma" size="2">-----Original Message-----<br><b>From:</b>
insight-users-bounces+millerjv=<a href="mailto:crd.ge.com@itk.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">crd.ge.com@itk.org</a>
[mailto:<a href="mailto:insight-users-bounces+millerjv=crd.ge.com@itk.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">insight-users-bounces+millerjv=crd.ge.com@itk.org</a>]<b>On Behalf Of
</b>Vicente Grau<br><b>Sent:</b> Monday, May 08, 2006 5:39 AM<br><b>To:</b>
Jim Miller; <a href="mailto:insight-users@itk.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">insight-users@itk.org</a><br><b>Subject:</b> Re: [Insight-users]
Filtering a tensor component accessed
withNthElementImageAdaptor<br><br></font></div>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>
</span></div><div style="direction: ltr;"><div></div><div style="direction: ltr;"><span class="e" id="q_10b1471c838759e1_3"><span class="gmail_quote">On 05/05/06, <b class="gmail_sendername">Jim
Miller</b> <<a href="mailto:millerjv@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">millerjv@gmail.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_10b1471c838759e1_5">
<div style="direction: ltr;"><span name="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><br>Jim<br><br><br><br><br></span></div>
</span></div><div style="direction: ltr;"><div style="direction: ltr;"></div><div style="direction: ltr;"><span class="e" id="q_10b1471c838759e1_7">
<div></div>
<div style="direction: ltr;"><span><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>
<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>
</span></div><div style="direction: ltr;"><div style="direction: ltr;"><span></span></div><div style="direction: ltr;"><span class="e" id="q_10b1471c838759e1_9">_______________________________________________<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 name="st">itk</span>.org</a><br></span></div><div style="direction: ltr;">
<span class="q"><a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.<span name="st">itk</span>.org/mailman/listinfo/insight-users</a>
<br><br><br></span></div><div style="direction: ltr;"></div>
<div style="direction: ltr;"></div><br></div></div><br><br clear="all"><br>-- </div><div style="direction: ltr;"><span class="q"><br>Vicente Grau<br>Wolfson Medical Vision
Laboratory<br>Department of Engineering Science<br>University of Oxford
</span></div><div style="direction: ltr;">
</div></blockquote></div><br><br clear="all"><br><br>