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

karali patra kpsr_in at yahoo.co.in
Wed Jan 16 02:12:34 EST 2008


Hi Mattt,
  I followed your suggestions. In addition to that I have changed the pixel type at line no 94 (of the original example code) according  to image format type (say for .bmp it is "typdef unsigned char      PixelType;")
  The file locations for read and write have been added in both line 158 and 159, respectively.
  reader->SetFileName( "C:\\cygwin\\bin\\ImageReadWrite\\MRI_head_092.bmp"  );
  writer->SetFileName( "C:\\cygwin\\bin\\ImageReadWrite\\MRI_head_092_w.bmp" );
  Now the program is reading and writing image files.
  Thanks to all insight users using this mail list. Special thanks to Matt for your prompt reply.
  Regards,
  Patra

att Kelsey <mkelsey at gmail.com> wrote:
  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 
> 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
>
>
>


       
---------------------------------
 Bring your gang together - do your thing.  Start your group.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20080116/efeea6ce/attachment.html


More information about the Insight-users mailing list