[Insight-users] NthElementImageAdaptor and ImageFileWriter

Miller, James V (Research) millerjv at crd.ge.com
Wed Jun 30 12:00:17 EDT 2004


I don't think you can use an adaptor as input to a file writer. 
 
You can use the AdaptImageFilter or VectorIndexSelectionCastImageFilter to
extract the component you want and pass that to the writer.
 
Jim
 
 

-----Original Message-----
From: jean-michel.rouet at philips.com [mailto:jean-michel.rouet at philips.com]
Sent: Wednesday, June 30, 2004 9:03 AM
To: ITK
Subject: [Insight-users] NthElementImageAdaptor and ImageFileWriter



Hi all, 

Is there a problem using ImageFileWriter with an itk::NthElementImageAdaptor
adaptor ? 
after a few tries, it appeared to me that the file generated is incorect. 

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> 
But when I view the output, the image looks interlaced (terrible!)... 
Am I doing sthg wrong. 
  
#include "itkImage.h" 
#include "itkImageFileReader.h" 
#include "itkImageFileWriter.h" 
#include "itkNthElementImageAdaptor.h" 

int main( int argc, char *argv[]) 
{ 
  
    typedef itk::Vector<float,3>                              VectPixelType;

    typedef itk::Image< VectPixelType, 3 >
VectImageType; 
    typedef itk::NthElementImageAdaptor<VectImageType,float> NthAdaptorType;

    typedef itk::ImageFileWriter< NthAdaptorType >
FloatWriterType; 

    // read a vect image 
    typedef  itk::ImageFileReader< VectImageType > ReaderType; 
    ReaderType::Pointer reader = ReaderType::New(); 
    reader->SetFileName( argv[1] ); 

    VectImageType::Pointer myVectImage = reader->GetOutput(); 
    reader->Update(); 
            
    FloatWriterType::Pointer fwriter = FloatWriterType::New(); 
    NthAdaptorType::Pointer adapt = NthAdaptorType::New(); 

    adapt->SetImage(myVectImage); 
    adapt->SelectNthElement(0); 

    fwriter->SetInput(adapt); 
    fwriter->SetFileName(argv[2]); 
    fwriter->Update(); 

    return 0; 
} 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20040630/e85d455f/attachment.htm


More information about the Insight-users mailing list