[Insight-users] NthElementImageAdaptor and ImageFileWriter
jean-michel.rouet at philips.com
jean-michel.rouet at philips.com
Wed Jun 30 09:02:45 EDT 2004
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/b6bc36da/attachment.html
More information about the Insight-users
mailing list