[Insight-users] (no subject)

john smith mkitkinsightuser at gmail.com
Mon Feb 14 17:49:09 EST 2011


Hello to everyone,
I am using visual studio 2010 with the help of cmake. I want to create a
program which change the extension of the file, for example makes a *
test.png* file to* test.jpeg* file. I have written the following code which
is compiled without failures. When I run the .exe file I get this message
(as it was expected):

*Usage:
name_of_project.exe inputImageFile  outputImageFile
*
I would like to ask what exactly I must type to the Command Prompt window
after running the .exe file to get the new .jpeg file.


-----------------code------------------------------------------------
---------------------------------------------------------------------------------------------------

#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif

#ifdef __BORLANDC__
#define ITK_LEAN_AND_MEAN
#endif

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


#include "itkImage.h"


int main( int argc, char ** argv )
{
  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( inputFilename );
  writer->SetFileName( outputFilename);



  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/20110215/f9921c08/attachment.htm>


More information about the Insight-users mailing list