<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman,new york,times,serif;font-size:12pt"><div>Hello All,<br><br>&nbsp; Here's a simple program to test the read/write classes in ITK.&nbsp; It works fine in Release mode (windows 7, VS 2008), but fails in Debug mode with read Access violation.<br>I did not using cmake for thhis program, but externally linked it to ITK libs. I suspect that the writer is experiencing a race condition. since I am not familiar with the internals of ITK (multi-threading etc...), I would appreciate if some one knowledgeable of ITK tries out the following program. <br><br>Thank you,<br>Emma<br><br><br><br>#include "itkBinaryThresholdImageFilter.h"<br><br>#include "itkImage.h"<br>#include "itkImageFileReader.h"<br>#include "itkImageFileWriter.h"<br><br>int main( int argc, char * argv[] )<br>{<br>&nbsp; if( argc &lt; 7 )<br>&nbsp;&nbsp;&nbsp;
 {<br>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; "Usage: " &lt;&lt; argv[0];<br>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; " inputImageFile outputImageFile ";&nbsp; <br>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; " lowerThreshold upperThreshold ";&nbsp; <br>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; " outsideValue insideValue&nbsp;&nbsp; "&nbsp; &lt;&lt; std::endl;&nbsp; <br>&nbsp;&nbsp;&nbsp; return EXIT_FAILURE;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; <br>&nbsp;<br>&nbsp; typedef&nbsp; unsigned char&nbsp; InputPixelType;<br>&nbsp; typedef&nbsp; unsigned char&nbsp; OutputPixelType;<br>&nbsp; <br>&nbsp; typedef itk::Image&lt; InputPixelType,&nbsp; 2 &gt;&nbsp;&nbsp; InputImageType;<br>&nbsp; typedef itk::Image&lt; OutputPixelType, 2 &gt;&nbsp;&nbsp; OutputImageType;<br>&nbsp;<br>&nbsp; typedef itk::BinaryThresholdImageFilter&lt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InputImageType, OutputImageType &gt;&nbsp;
 FilterType;<br>&nbsp;<br>&nbsp; typedef itk::ImageFileReader&lt; InputImageType &gt;&nbsp; ReaderType;<br>&nbsp; <br>&nbsp; typedef itk::ImageFileWriter&lt; OutputImageType &gt;&nbsp; WriterType;<br>&nbsp; <br>&nbsp; ReaderType::Pointer reader = ReaderType::New();<br>&nbsp; FilterType::Pointer filter = FilterType::New();<br><br>&nbsp; WriterType::Pointer writer = WriterType::New();<br>&nbsp; writer-&gt;SetInput( filter-&gt;GetOutput() );<br>&nbsp; reader-&gt;SetFileName( argv[1] );<br>&nbsp;<br>&nbsp; filter-&gt;SetInput( reader-&gt;GetOutput() );<br><br>&nbsp; const OutputPixelType outsideValue = atoi( argv[5] );<br>&nbsp; const OutputPixelType insideValue&nbsp; = atoi( argv[6] );<br><br>&nbsp; filter-&gt;SetOutsideValue( outsideValue );<br>&nbsp; filter-&gt;SetInsideValue(&nbsp; insideValue&nbsp; );<br>&nbsp;<br><br>&nbsp; const InputPixelType lowerThreshold = atoi( argv[3] );<br>&nbsp; const InputPixelType upperThreshold = atoi( argv[4]
 );<br><br>&nbsp; filter-&gt;SetLowerThreshold( lowerThreshold );<br>&nbsp; filter-&gt;SetUpperThreshold( upperThreshold );<br>&nbsp;<br>&nbsp; filter-&gt;Update();<br>&nbsp; writer-&gt;SetFileName( argv[2] );<br>&nbsp; writer-&gt;Update();<br><br>&nbsp; return EXIT_SUCCESS;<br>}<br><br><br></div>
</div><br>







      </body></html>