<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=US-ASCII">


<META content="MSHTML 6.00.2800.1276" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=890065515-30062004><FONT face=Verdana color=#0000ff size=2>I 
don't think you can use an adaptor as input to a file writer. 
</FONT></SPAN></DIV>
<DIV><SPAN class=890065515-30062004><FONT face=Verdana color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=890065515-30062004><FONT face=Verdana color=#0000ff size=2>You 
can use the AdaptImageFilter or VectorIndexSelectionCastImageFilter 
to</FONT></SPAN></DIV>
<DIV><SPAN class=890065515-30062004><FONT face=Verdana color=#0000ff 
size=2>extract the component you want and pass that to the 
writer.</FONT></SPAN></DIV>
<DIV><SPAN class=890065515-30062004><FONT face=Verdana color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=890065515-30062004><FONT face=Verdana color=#0000ff 
size=2>Jim</FONT></SPAN></DIV>
<DIV><SPAN class=890065515-30062004><FONT face=Verdana color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=890065515-30062004><FONT face=Verdana color=#0000ff 
size=2></FONT></SPAN>&nbsp;</DIV>
<BLOCKQUOTE>
  <DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma 
  size=2>-----Original Message-----<BR><B>From:</B> 
  jean-michel.rouet@philips.com 
  [mailto:jean-michel.rouet@philips.com]<BR><B>Sent:</B> Wednesday, June 30, 
  2004 9:03 AM<BR><B>To:</B> ITK<BR><B>Subject:</B> [Insight-users] 
  NthElementImageAdaptor and ImageFileWriter<BR><BR></FONT></DIV><BR><FONT 
  face=sans-serif size=2>Hi all,</FONT> <BR><BR><FONT face=sans-serif size=2>Is 
  there a problem using ImageFileWriter with an itk::NthElementImageAdaptor 
  adaptor ?</FONT> <BR><FONT face=sans-serif size=2>after a few tries, it 
  appeared to me that the file generated is incorect.</FONT> <BR><BR><FONT 
  face=sans-serif size=2>The following programs reads a 
  itk::Image&lt;Vector&lt;float,3&gt;,3&gt; image and writes the first component 
  into a separate image as itk::Image&lt;float,3&gt;</FONT> <BR><FONT 
  face=sans-serif size=2>But when I view the output, the image looks interlaced 
  (terrible!)... </FONT><BR><FONT face=sans-serif size=2>Am I doing sthg 
  wrong.</FONT> <BR><FONT color=#008000 size=2><TT>&nbsp;</TT></FONT> <BR><FONT 
  color=blue size=2><TT>#include</TT></FONT><FONT size=2><TT> 
  "itkImage.h"</TT></FONT> <BR><FONT color=blue 
  size=2><TT>#include</TT></FONT><FONT size=2><TT> 
  "itkImageFileReader.h"</TT></FONT> <BR><FONT color=blue 
  size=2><TT>#include</TT></FONT><FONT size=2><TT> 
  "itkImageFileWriter.h"</TT></FONT> <BR><FONT color=blue 
  size=2><TT>#include</TT></FONT><FONT size=2><TT> 
  "itkNthElementImageAdaptor.h"</TT></FONT> <BR><BR><FONT color=blue 
  size=2><TT>int</TT></FONT><FONT size=2><TT> main( </TT></FONT><FONT color=blue 
  size=2><TT>int</TT></FONT><FONT size=2><TT> argc, </TT></FONT><FONT color=blue 
  size=2><TT>char</TT></FONT><FONT size=2><TT> *argv[])</TT></FONT> <BR><FONT 
  size=2><TT>{</TT></FONT> <BR><FONT size=2><TT>&nbsp; </TT></FONT><BR><FONT 
  size=2><TT>&nbsp; &nbsp; </TT></FONT><FONT color=blue 
  size=2><TT>typedef</TT></FONT><FONT size=2><TT> 
  itk::Vector&lt;</TT></FONT><FONT color=blue size=2><TT>float</TT></FONT><FONT 
  size=2><TT>,3&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;VectPixelType;</TT></FONT> 
  <BR><FONT size=2><TT>&nbsp; &nbsp; </TT></FONT><FONT color=blue 
  size=2><TT>typedef</TT></FONT><FONT size=2><TT> itk::Image&lt; VectPixelType, 
  3 &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
  VectImageType; </TT></FONT><BR><FONT size=2><TT>&nbsp; &nbsp; 
  </TT></FONT><FONT color=blue size=2><TT>typedef</TT></FONT><FONT size=2><TT> 
  itk::NthElementImageAdaptor&lt;VectImageType,</TT></FONT><FONT color=blue 
  size=2><TT>float</TT></FONT><FONT size=2><TT>&gt; NthAdaptorType;</TT></FONT> 
  <BR><FONT size=2><TT>&nbsp; &nbsp; </TT></FONT><FONT color=blue 
  size=2><TT>typedef</TT></FONT><FONT size=2><TT> itk::ImageFileWriter&lt; 
  NthAdaptorType &gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
  FloatWriterType;</TT></FONT> <BR><BR><FONT size=2><TT>&nbsp; &nbsp; 
  </TT></FONT><FONT color=#008000 size=2><TT>// read a vect image</TT></FONT> 
  <BR><FONT size=2><TT>&nbsp; &nbsp; </TT></FONT><FONT color=blue 
  size=2><TT>typedef</TT></FONT><FONT size=2><TT> &nbsp;itk::ImageFileReader&lt; 
  VectImageType &gt; ReaderType;</TT></FONT> <BR><FONT size=2><TT>&nbsp; &nbsp; 
  ReaderType::Pointer reader = ReaderType::New();</TT></FONT> <BR><FONT 
  size=2><TT>&nbsp; &nbsp; reader-&gt;SetFileName( argv[1] );</TT></FONT> 
  <BR><BR><FONT size=2><TT>&nbsp; &nbsp; VectImageType::Pointer myVectImage = 
  reader-&gt;GetOutput();</TT></FONT> <BR><FONT size=2><TT>&nbsp; &nbsp; 
  reader-&gt;Update();</TT></FONT> <BR><FONT size=2><TT>&nbsp; &nbsp; &nbsp; 
  &nbsp; &nbsp; &nbsp; </TT></FONT><BR><FONT size=2><TT>&nbsp; &nbsp; 
  FloatWriterType::Pointer fwriter = FloatWriterType::New();</TT></FONT> 
  <BR><FONT size=2><TT>&nbsp; &nbsp; NthAdaptorType::Pointer adapt = 
  NthAdaptorType::New();</TT></FONT> <BR><BR><FONT size=2><TT>&nbsp; &nbsp; 
  adapt-&gt;SetImage(myVectImage);</TT></FONT> <BR><FONT size=2><TT>&nbsp; 
  &nbsp; adapt-&gt;SelectNthElement(0);</TT></FONT> <BR><BR><FONT 
  size=2><TT>&nbsp; &nbsp; fwriter-&gt;SetInput(adapt);</TT></FONT> <BR><FONT 
  size=2><TT>&nbsp; &nbsp; fwriter-&gt;SetFileName(argv[2]);</TT></FONT> 
  <BR><FONT size=2><TT>&nbsp; &nbsp; fwriter-&gt;Update();</TT></FONT> 
  <BR><BR><FONT size=2><TT>&nbsp; &nbsp; </TT></FONT><FONT color=blue 
  size=2><TT>return</TT></FONT><FONT size=2><TT> 0;</TT></FONT> <BR><FONT 
  size=2><TT>}</TT></FONT> <BR></BLOCKQUOTE></BODY></HTML>