[Insight-users] Problem in Image Writing

amit suveer amitsuveer at gmail.com
Fri Sep 28 07:26:19 EDT 2012


Hello,

I am facing problem in writing the image. I have written this code for
writing

Here
enFaceImageType is:

typedef float EnFacePixelType;
typedef itk::Image< EnFacePixelType, 2 > enFaceImageType;

int writeImage( const string &sFileName, const enFaceImageType::Pointer
&enFaceImage )
{
// Define the image to be written to be of type unsigned char:
 typedef unsigned char WritePixelType;
 const   unsigned int Dimension = 2;
typedef itk::Image<WritePixelType, Dimension> WriteImageType;

// Rescaling image for writing:
typedef itk::RescaleIntensityImageFilter<enFaceImageType,WriteImageType >
RescaleFilter;
 RescaleFilter::Pointer rescale = RescaleFilter::New();
// Set the scale range:
rescale->SetOutputMinimum(   0 );
 rescale->SetOutputMaximum( 255 );
rescale->SetInput( enFaceImage );

typedef itk::ImageFileWriter< WriteImageType > newWriterType;
 newWriterType::Pointer imageWriter = newWriterType::New();
imageWriter->SetInput( rescale->GetOutput() );
 imageWriter->SetFileName( sFileName.c_str() );
try {
imageWriter->Update();
 }
catch( itk::ExceptionObject & err ) {
       std::cout << "ExceptionObject caught !" << std::endl;
     std::cout << err << std::endl;
     return -1;
   }
 cout << "writeEnFaceImage(): Successfully wrote to " << sFileName << "!"
<< endl;
return EXIT_SUCCESS;
}

Crash is happening in Update() call. I traced the call stack, the site of
crash is:

ImageIOBase::Pointer ImageIOFactory::CreateImageIO(const char* path,
FileModeType mode)
{

  RegisterBuiltInFactories();

  std::list<ImageIOBase::Pointer> possibleImageIO;
  std::list<LightObject::Pointer> allobjects
= ObjectFactoryBase::CreateAllInstance("itkImageIOBase");  -----> this call
...
.

.
.
.
}

This call return allobjects [0] = { m_pointer = ??? }
I think it is not creating any instance of "itkImageIOBase" so no memory is
allocated to write data. What could be the possible reason for this ?

Error I am getting is -

First-chance exception at 0x0d69c2b0 (CI.SD.Algorithms.dll) in
ProcessInvocation86.exe: 0xC0000005: Access violation reading location
0x0000000f.
A first chance exception of type 'System.AccessViolationException' occurred
in CI.SD.Algorithms.dll
An exception of type 'System.AccessViolationException' occurred
in CI.SD.Algorithms.dll

Additional information: Attempted to read or write protected memory. This
is often an indication that other memory is corrupt.
The thread 'Win32 Thread' (0x1454) has exited with code 0 (0x0).




-- 
Thanks & Regards,
- - -

Amit Suveer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120928/aaac070e/attachment.htm>


More information about the Insight-users mailing list