[Insight-users] Blank output file
Jessica Ford
gingerbaby at hotmail.com
Fri Jun 18 18:53:25 EDT 2004
Hi,
I'm trying to write a simple program that read a file with ImageFileReader
and output the file with ImageFileWriter. I want to see if it can read in
"Dicom" file type. I first run my program with "png" file type. When I run
my program, I get a file with no image; it was all black. I don't know
what's wrong. Here's my code:
#include "itkImage.h"
#include "itkCastImageFilter.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include <iostream>
int main(int argc, char *argv[] )
{
typedef itk::Image< unsigned short, 2 > ImageType;
typedef itk::ImageFileReader<ImageType> ReaderType;
typedef itk::ImageFileWriter<ImageType> WriterType;
if( argc < 2 )
{
std::cerr << "Missing Parameters " << std::endl;
std::cerr << "Usage: " << argv[0];
std::cerr << " inputFileImage outputFileImage" << std::endl;
return 1;
}
ImageType::Pointer image = ImageType::New();
ReaderType::Pointer reader = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
reader->SetFileName( argv[1] );
writer->SetFileName( argv[2] );
writer->SetInput( reader->GetOutput() );
try
{ writer->Update();
}
catch (itk::ExceptionObject & err)
{
std::cout << "Exception object caught! " << std::endl;
std::cout << err << std::endl;
return -1;
}
return 0;
}
All help would be appreciated.
Jessica
_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail
More information about the Insight-users
mailing list