[Insight-users] Reading and Writing Images-Image Type Conversion
Gideon Nimako
ginima2004 at yahoo.co.uk
Mon Aug 17 18:22:02 EDT 2009
Dear all
I am converting an image from jpg to tiff and cant seem to find the
converted image in my directory. Where the converted image go. When you
WRITE an image where does it go.
Please help me.
Its very urgent
The Code is as below
.....................................................................................................................
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkImage.h"
int main( int argc, char ** argv )
{
// Verify the number of parameters in the command line
if( argc < 3 )
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " inputImageFile outputImageFile " << std::endl;
return EXIT_FAILURE;
}
typedef short PixelType;
const unsigned int Dimension = 2;
typedef itk::Image< PixelType, Dimension > ImageType;
typedef itk::ImageFileReader< ImageType > ReaderType;
typedef itk::ImageFileWriter< ImageType > WriterType;
ReaderType::Pointer reader = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
const char * inputFilename = argv[1];
const char * outputFilename = argv[2];
reader->SetFileName( "original.jpg" );
writer->SetFileName( "original.tiff" );
writer->SetInput( reader->GetOutput() );
try
{
writer->Update();
}
catch( itk::ExceptionObject & err )
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090817/92964fb5/attachment.htm>
More information about the Insight-users
mailing list