[Insight-users] reading a dicom image

Syrine Sahmim syrine.sahmim at yahoo.fr
Sat Jun 20 06:31:13 EDT 2009


hi all,
i try to read a dicom image
i write this 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 "itkRescaleIntensityImageFilter.h"
#include "itkGDCMImageIO.h"
#include <list>
#include <fstream>


int main( int argc, char* argv[] )
{if( argc < 5 )
    {
    std::cerr << "Usage: " << std::endl;
    std::cerr << argv[0] << " DicomImage OutputDicomImage ";
        std::cerr << " OutputImage RescaleDicomImage\n";
    return EXIT_FAILURE;
    }
typedef signed short InputPixelType;
  const unsigned int   InputDimension = 2;

  typedef itk::Image< InputPixelType, InputDimension > InputImageType;
  typedef itk::ImageFileReader< InputImageType > ReaderType;

  ReaderType::Pointer reader = ReaderType::New();
  reader->SetFileName( "C:\Documents and Settings\Sirouna\Mes documents\Master\imgdicom" );
  typedef itk::GDCMImageIO           ImageIOType;

  ImageIOType::Pointer gdcmImageIO = ImageIOType::New();
  
  reader->SetImageIO( gdcmImageIO );
  try
    {
    reader->Update();
    }
  catch (itk::ExceptionObject & e)
    {
    std::cerr << "exception in file reader " << std::endl;
    std::cerr << e << std::endl;
    return EXIT_FAILURE;
    }
}
i want to know where i must add the image path? is it correct my code?
when i build the project i have those warnings:
------ Build started: Project: DicomImageReadWrite, Configuration: Debug Win32 ------
Compiling...
DicomImageReadWrite.cxx
..\pj02dicom\DicomImageReadWrite.cxx(32) : warning C4129: 'D' : unrecognized character escape sequence
..\pj02dicom\DicomImageReadWrite.cxx(32) : warning C4129: 'S' : unrecognized character escape sequence
..\pj02dicom\DicomImageReadWrite.cxx(32) : warning C4129: 'M' : unrecognized character escape sequence
..\pj02dicom\DicomImageReadWrite.cxx(32) : warning C4129: 'M' : unrecognized character escape sequence
..\pj02dicom\DicomImageReadWrite.cxx(32) : warning C4129: 'i' : unrecognized character escape sequence
Linking...
   Creating library C:\Documents and
Settings\Sirouna\Bureau\prjitk\pj02dicom_b\Debug\DicomImageReadWrite.lib
and object C:\Documents and
Settings\Sirouna\Bureau\prjitk\pj02dicom_b\Debug\DicomImageReadWrite.exp
Embedding manifest...
Build
log was saved at "file://c:\Documents and
Settings\Sirouna\Bureau\prjitk\pj02dicom_b\DicomImageReadWrite.dir\Debug\BuildLog.htm"
DicomImageReadWrite - 0 error(s), 5 warning(s)
------ Skipped Build: Project: ALL_BUILD, Configuration: Debug Win32 ------
Project not selected to build for this solution configuration 
========== Build: 1 succeeded, 0 failed, 1 up-to-date, 1 skipped ==========
and when i debogue the program i have those errors:
'DicomImageReadWrite.exe':
Loaded 'C:\Documents and
Settings\Sirouna\Bureau\prjitk\pj02dicom_b\debug\DicomImageReadWrite.exe',
Symbols loaded.
'DicomImageReadWrite.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', No symbols loaded.
'DicomImageReadWrite.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', No symbols loaded.
'DicomImageReadWrite.exe': Loaded 'C:\WINDOWS\system32\snmpapi.dll', No symbols loaded.
'DicomImageReadWrite.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', No symbols loaded.
'DicomImageReadWrite.exe': Loaded 'C:\WINDOWS\system32\ws2_32.dll', No symbols loaded.
'DicomImageReadWrite.exe': Loaded 'C:\WINDOWS\system32\ws2help.dll', No symbols loaded.
'DicomImageReadWrite.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll', No symbols loaded.
'DicomImageReadWrite.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll', No symbols loaded.
'DicomImageReadWrite.exe':
Loaded
'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.DebugCRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_f75eb16c\msvcp80d.dll',
Symbols loaded.
'DicomImageReadWrite.exe': Loaded
'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.DebugCRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_f75eb16c\msvcr80d.dll',
Symbols loaded.
'DicomImageReadWrite.exe': Loaded 'C:\WINDOWS\system32\user32.dll', No symbols loaded.
'DicomImageReadWrite.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll', No symbols loaded.
The program '[3472] DicomImageReadWrite.exe: Native' has exited with code 1 (0x1).
have you an idea to how can  i do to read the dicom image


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20090620/e53beca4/attachment-0001.htm>


More information about the Insight-users mailing list