<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2802" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=138052114-08052006><FONT face=Arial color=#0000ff 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 class=138052114-08052006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=138052114-08052006><FONT face=Arial color=#0000ff size=2>Can
you run another experiment for me?</FONT></SPAN></DIV>
<DIV><SPAN class=138052114-08052006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=138052114-08052006><FONT face=Arial color=#0000ff size=2>Edit
Insight/Code/Common/itkImageBase.txx. On line 239, could you change the
line from</FONT></SPAN></DIV>
<DIV><SPAN class=138052114-08052006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=138052114-08052006><FONT face=Arial color=#0000ff
size=2> m_Spacing = imgData->m_Spacing;</FONT></SPAN></DIV>
<DIV><SPAN class=138052114-08052006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=138052114-08052006><FONT face=Arial color=#0000ff
size=2>to</FONT></SPAN></DIV>
<DIV><SPAN class=138052114-08052006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=138052114-08052006><FONT face=Arial color=#0000ff size=2>
m_Spacing = imgData->GetSpacing();</FONT></SPAN></DIV>
<DIV><SPAN class=138052114-08052006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=138052114-08052006><FONT face=Arial color=#0000ff 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 class=138052114-08052006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=138052114-08052006><FONT face=Arial color=#0000ff 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 class=138052114-08052006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=138052114-08052006><FONT face=Arial color=#0000ff
size=2>Jim</FONT></SPAN></DIV>
<BLOCKQUOTE>
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B>
insight-users-bounces+millerjv=crd.ge.com@itk.org
[mailto:insight-users-bounces+millerjv=crd.ge.com@itk.org]<B>On Behalf Of
</B>Vicente Grau<BR><B>Sent:</B> Monday, May 08, 2006 5:39 AM<BR><B>To:</B>
Jim Miller; insight-users@itk.org<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>
<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="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">
<DIV style="DIRECTION: ltr"><SPAN class=st id=st 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
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 onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:vgrauc@googlemail.com"
target=_blank>vgrauc@googlemail.com</A>> wrote:</SPAN></SPAN></DIV>
<DIV style="DIRECTION: ltr">
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid"></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 onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:Insight-users@itk.org" target=_blank>Insight-users@<SPAN
class=st id=st name="st">itk</SPAN>.org</A><BR><A
onclick="return top.js.OpenExtLink(window,event,this)"
href="http://www.itk.org/mailman/listinfo/insight-users"
target=_blank>http://www.<SPAN class=st id=st
name="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
</BLOCKQUOTE></BODY></HTML>