<div style="background-color:rgb(255,255,255)"><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px">Hello,</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px">

<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px">I am facing problem in writing the image. I have written this code for writing</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px">

<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px">Here </div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px">enFaceImageType is:</div>

<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px"><br></div><div><font color="#222222" face="arial, sans-serif">typedef float EnFacePixelType;<span class="Apple-tab-span" style="white-space:pre">        </span></font></div>

<div><font color="#222222" face="arial, sans-serif">typedef itk::Image&lt; EnFacePixelType, 2 &gt; enFaceImageType;</font></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px">

<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px">int writeImage( const string &amp;sFileName, const enFaceImageType::Pointer &amp;enFaceImage )</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px">

{</div></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px;background-color:rgb(255,255,255)"><span style="white-space:pre-wrap">        </span>// Define the image to be written to be of type unsigned char:</div>

<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px;background-color:rgb(255,255,255)"><div><span style="white-space:pre-wrap">        </span>typedef unsigned char<span style="white-space:pre-wrap">        </span>WritePixelType;</div>

<div><span style="white-space:pre-wrap">        </span>const   unsigned int<span style="white-space:pre-wrap">        </span>Dimension = 2;</div><div><span style="white-space:pre-wrap">        </span>typedef itk::Image&lt;WritePixelType, Dimension&gt; WriteImageType;</div>

<div><br></div><div><span style="white-space:pre-wrap">        </span>// Rescaling image for writing:</div><div><span style="white-space:pre-wrap">        </span>typedef itk::RescaleIntensityImageFilter&lt;enFaceImageType,WriteImageType &gt; RescaleFilter;</div>

<div><span style="white-space:pre-wrap">        </span>RescaleFilter::Pointer rescale = RescaleFilter::New();</div><div><span style="white-space:pre-wrap">        </span>// Set the scale range:</div><div><span style="white-space:pre-wrap">        </span>rescale-&gt;SetOutputMinimum(   0 );</div>

<div><span style="white-space:pre-wrap">        </span>rescale-&gt;SetOutputMaximum( 255 );</div><div><span style="white-space:pre-wrap">        </span>rescale-&gt;SetInput( enFaceImage );</div><div><br></div><div><span style="white-space:pre-wrap">        </span>typedef itk::ImageFileWriter&lt; WriteImageType &gt; newWriterType;</div>

<div><span style="white-space:pre-wrap">        </span>newWriterType::Pointer imageWriter = newWriterType::New();</div><div><span style="white-space:pre-wrap">        </span>imageWriter-&gt;SetInput( rescale-&gt;GetOutput() );</div><div>

<span style="white-space:pre-wrap">        </span>imageWriter-&gt;SetFileName( sFileName.c_str() );</div><div><span style="white-space:pre-wrap">        </span>try {</div><div><span style="white-space:pre-wrap">                </span>imageWriter-&gt;Update();</div>

<div><span style="white-space:pre-wrap">        </span>}</div><div><span style="white-space:pre-wrap">        </span>catch( itk::ExceptionObject &amp; err ) { </div><div>      <span style="white-space:pre-wrap">        </span>std::cout &lt;&lt; &quot;ExceptionObject caught !&quot; &lt;&lt; std::endl; </div>

<div>    <span style="white-space:pre-wrap">        </span>std::cout &lt;&lt; err &lt;&lt; std::endl; </div><div>    <span style="white-space:pre-wrap">        </span>return -1;</div><div>  <span style="white-space:pre-wrap">        </span>}</div>

<div><span style="white-space:pre-wrap">        </span>cout &lt;&lt; &quot;writeEnFaceImage(): Successfully wrote to &quot; &lt;&lt; sFileName &lt;&lt; &quot;!&quot; &lt;&lt; endl;</div><div><span style="white-space:pre-wrap">        </span>return EXIT_SUCCESS;</div>

<div>}</div></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px;background-color:rgb(255,255,255)">

Crash is happening in Update() call. I traced the call stack, the site of crash is: </div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px;background-color:rgb(255,255,255)"><br>

</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px;background-color:rgb(255,255,255)"><div>ImageIOBase::Pointer ImageIOFactory::CreateImageIO(const char* path, FileModeType mode)</div>

<div>{</div><div><br></div><div>  RegisterBuiltInFactories();</div><div><br></div><div>  std::list&lt;ImageIOBase::Pointer&gt; possibleImageIO;</div><div>  std::list&lt;LightObject::Pointer&gt; allobjects = ObjectFactoryBase::CreateAllInstance(&quot;itkImageIOBase&quot;);  -----&gt; this call </div>

</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px;background-color:rgb(255,255,255)">...</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px;background-color:rgb(255,255,255)">

.</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px;background-color:rgb(255,255,255)">

.</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px;background-color:rgb(255,255,255)">.</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px;background-color:rgb(255,255,255)">

.</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px;background-color:rgb(255,255,255)">}</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px;background-color:rgb(255,255,255)">

<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px;background-color:rgb(255,255,255)">This call return allobjects [0] = { m_pointer = ??? }</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px;background-color:rgb(255,255,255)">

I think it is not creating any instance of &quot;itkImageIOBase&quot; so no memory is allocated to write data. What could be the possible reason for this ?</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.727272033691406px;background-color:rgb(255,255,255)">

<br></div><div>Error I am getting is - </div><div><br></div><div><div>First-chance exception at 0x0d69c2b0 (CI.SD.Algorithms.dll) in ProcessInvocation86.exe: 0xC0000005: Access violation reading location 0x0000000f.</div>

<div>A first chance exception of type &#39;System.AccessViolationException&#39; occurred in CI.SD.Algorithms.dll</div><div>An exception of type &#39;System.AccessViolationException&#39; occurred in CI.SD.Algorithms.dll</div>

<div><br></div><div>Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.</div><div>The thread &#39;Win32 Thread&#39; (0x1454) has exited with code 0 (0x0).</div>

</div><div><br></div><div><br></div><div><br></div><div><br></div>-- <br><span style="font-family:georgia,serif">Thanks &amp; Regards,<br>- - -<br><br>Amit Suveer </span><font face="georgia, serif"><br><br></font>