[ITK] Problem with writing image

Constantinus Spanakis c.spanakis83 at gmail.com
Mon Jul 6 05:00:10 EDT 2015


Hello, I want to copy an image. But all I get is a blank image. What;s
the problem? Here is the code:

#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"

#define NULL 0

int main(int argc, char *argv[]){
        const char *filename=argv[1];
        const char *filename2=argv[2];
        typedef itk::Image< unsigned short, 2 > ImageType;
        typedef itk::ImageFileReader<ImageType> Reader;
        typedef itk::ImageFileWriter<ImageType> Writer;



        Reader::Pointer reader=Reader::New();

        reader->SetFileName(filename);
        ImageType::Pointer image=reader->GetOutput();
        reader->Update();





        Writer::Pointer writer=Writer::New();




        writer->SetFileName(filename2);
        writer->SetInput(reader->GetOutput());
        writer->Update();



        return EXIT_SUCCESS;
}


More information about the Community mailing list