[Insight-users] Re: Reading and writing image files using ITK and Cmake

Matt Kelsey mkelsey at gmail.com
Tue Jan 15 09:14:47 EST 2008


Hello KPatra,
I think you will find that your message is due to the code on lines 59
- 68 in ImageReadWrite.cxx, i.e.
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;
    }

whereas the program checks that you have provided input and output
file name.  In your example you are providing these statically.  You
can either remove the code above requiring argc>=3 or just provide
your image file name as command line parameters with the original
example code.  Good luck.

Matt

>
> ---------- Forwarded message ----------
> From: karali patra <kpsr_in at yahoo.co.in>
> To: insight-users at itk.org
> Date: Tue, 15 Jan 2008 03:46:22 +0000 (GMT)
> Subject: [Insight-users] Reading and writing image files using ITK and Cmake
> Dear All,
> I am a new user of ITK. I am trying to read and and write image files using the ITK and Cmakesetup (for configuring).I successfully run the helloWorld code(to test the itk is running properly).
> I have copied the
> Examples/IO/ImageReadWrite.cxx.
> file to another directory "ImageReadWrite". I have created the following  'CMakeLists.txt' file in the same directory.
>
> PROJECT(ImageReadWrite)
> # Find ITK.
> FIND_PACKAGE(ITK REQUIRED)
> IF(ITK_FOUND)
>   INCLUDE(${ITK_USE_FILE})
> ENDIF(ITK_FOUND)
> ADD_EXECUTABLE(ImageReadWrite ImageReadWrite.cxx )
> TARGET_LINK_LIBRARIES(ImageReadWrite  ITKIO)
> ......
> I have modified the ImageReadWrite.cxx code in the following place
>
> reader->SetFileName( "BrainProtonDensitySlice.png"  );
>   writer->SetFileName( "BrainProtonDensitySlice_w.png" );
>
> I have also copied the image file "BrainProtonDensitySlice.png" to the same directory.
>
> Now using the CMakeSetUp, I configured it (source and binary build directing are same). I got the ImageReadWrite.dsw workspace. I opened this in Visual Studio 6 and built all files successfully. I run the ImageReadWrite.exe file. It gave following output
> "
> usage:
> C:\...\ImageReadWrite\Debug\ImageReadWrite.exe inputImageFile outputImageFile"
>
> The program is not reading and writing the image. Please suggest what went wrong and help me correcting the problem
> Thanks
> KPatra
> Singapore
>
>
>


More information about the Insight-users mailing list