[Insight-users] Access violation when reading images with itk

Boettcher, Dr. Peter Boettcher at kleintierklinik.uni-leipzig.de
Sun Apr 6 15:33:06 EDT 2008


I have problems reading images into my itk-MFC-application.
 
I have two images I use for testing. Both are grey-scale images stored as tif and as bmp respectively. Both images can be loaded nicely with the ImageViewer-Application. 
I get an access violation error when I execute reader->Update(). when I give a invalide filename to the reader it executes the update command, and gives me an ExceptionObject error.
 
 
Regards, Peter.
 
 
 
 
Here is my code
 
CString FileName;
HRESULT hResult;
 
 CFileDialog dlg(TRUE, NULL, NULL, OFN_FILEMUSTEXIST, NULL, this);
 
 hResult = (int)dlg.DoModal();
 if(FAILED(hResult)) {
  return;
 }
 FileName = dlg.GetFileName();

  typedef itk::Image< unsigned short, 2 > ImageType;
  typedef itk::ImageFileReader< ImageType > ReaderType;
  ReaderType::Pointer reader = ReaderType::New();
 reader->SetFileName(FileName);
 
 
 try { 
      std::cout << "Writing image: " << "daga" << std::endl;
      reader->Update();
    } 
    catch( itk::ExceptionObject & err ) { 
      
      std::cerr << "ERROR: ExceptionObject caught !" << std::endl; 
      std::cerr << err << std::endl; 
    } 

 
------------------------------------
Peter Böttcher, Dr med vet, DipECVS
European Veterinary Specialist in Surgery
Fachtierarzt für Kleintierchirurgie
Klinik für Kleintiere 
Universität Leipzig 
An den Tierkliniken 23 
D-04103 Leipzig (Germany)
Tel: +49-341-9738700 
Fax: +49-341-9738799
email: boettcher at kleintierklinik.uni-leipzig.de

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


More information about the Insight-users mailing list