<!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> </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> </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> </DIV>
<DIV><SPAN class=890065515-30062004><FONT face=Verdana color=#0000ff
size=2></FONT></SPAN> </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<Vector<float,3>,3> image and writes the first component
into a separate image as itk::Image<float,3></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> </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> </TT></FONT><BR><FONT
size=2><TT> </TT></FONT><FONT color=blue
size=2><TT>typedef</TT></FONT><FONT size=2><TT>
itk::Vector<</TT></FONT><FONT color=blue size=2><TT>float</TT></FONT><FONT
size=2><TT>,3>
VectPixelType;</TT></FONT>
<BR><FONT size=2><TT> </TT></FONT><FONT color=blue
size=2><TT>typedef</TT></FONT><FONT size=2><TT> itk::Image< VectPixelType,
3 >
VectImageType; </TT></FONT><BR><FONT size=2><TT>
</TT></FONT><FONT color=blue size=2><TT>typedef</TT></FONT><FONT size=2><TT>
itk::NthElementImageAdaptor<VectImageType,</TT></FONT><FONT color=blue
size=2><TT>float</TT></FONT><FONT size=2><TT>> NthAdaptorType;</TT></FONT>
<BR><FONT size=2><TT> </TT></FONT><FONT color=blue
size=2><TT>typedef</TT></FONT><FONT size=2><TT> itk::ImageFileWriter<
NthAdaptorType >
FloatWriterType;</TT></FONT> <BR><BR><FONT size=2><TT>
</TT></FONT><FONT color=#008000 size=2><TT>// read a vect image</TT></FONT>
<BR><FONT size=2><TT> </TT></FONT><FONT color=blue
size=2><TT>typedef</TT></FONT><FONT size=2><TT> itk::ImageFileReader<
VectImageType > ReaderType;</TT></FONT> <BR><FONT size=2><TT>
ReaderType::Pointer reader = ReaderType::New();</TT></FONT> <BR><FONT
size=2><TT> reader->SetFileName( argv[1] );</TT></FONT>
<BR><BR><FONT size=2><TT> VectImageType::Pointer myVectImage =
reader->GetOutput();</TT></FONT> <BR><FONT size=2><TT>
reader->Update();</TT></FONT> <BR><FONT size=2><TT>
</TT></FONT><BR><FONT size=2><TT>
FloatWriterType::Pointer fwriter = FloatWriterType::New();</TT></FONT>
<BR><FONT size=2><TT> NthAdaptorType::Pointer adapt =
NthAdaptorType::New();</TT></FONT> <BR><BR><FONT size=2><TT>
adapt->SetImage(myVectImage);</TT></FONT> <BR><FONT size=2><TT>
adapt->SelectNthElement(0);</TT></FONT> <BR><BR><FONT
size=2><TT> fwriter->SetInput(adapt);</TT></FONT> <BR><FONT
size=2><TT> fwriter->SetFileName(argv[2]);</TT></FONT>
<BR><FONT size=2><TT> fwriter->Update();</TT></FONT>
<BR><BR><FONT size=2><TT> </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>