<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> Here's a simple program to test the read/write classes in ITK. 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> if( argc < 7 )<br>
{<br> std::cerr << "Usage: " << argv[0];<br> std::cerr << " inputImageFile outputImageFile "; <br> std::cerr << " lowerThreshold upperThreshold "; <br> std::cerr << " outsideValue insideValue " << std::endl; <br> return EXIT_FAILURE;<br> }<br> <br> <br> typedef unsigned char InputPixelType;<br> typedef unsigned char OutputPixelType;<br> <br> typedef itk::Image< InputPixelType, 2 > InputImageType;<br> typedef itk::Image< OutputPixelType, 2 > OutputImageType;<br> <br> typedef itk::BinaryThresholdImageFilter<<br> InputImageType, OutputImageType >
FilterType;<br> <br> typedef itk::ImageFileReader< InputImageType > ReaderType;<br> <br> typedef itk::ImageFileWriter< OutputImageType > WriterType;<br> <br> ReaderType::Pointer reader = ReaderType::New();<br> FilterType::Pointer filter = FilterType::New();<br><br> WriterType::Pointer writer = WriterType::New();<br> writer->SetInput( filter->GetOutput() );<br> reader->SetFileName( argv[1] );<br> <br> filter->SetInput( reader->GetOutput() );<br><br> const OutputPixelType outsideValue = atoi( argv[5] );<br> const OutputPixelType insideValue = atoi( argv[6] );<br><br> filter->SetOutsideValue( outsideValue );<br> filter->SetInsideValue( insideValue );<br> <br><br> const InputPixelType lowerThreshold = atoi( argv[3] );<br> const InputPixelType upperThreshold = atoi( argv[4]
);<br><br> filter->SetLowerThreshold( lowerThreshold );<br> filter->SetUpperThreshold( upperThreshold );<br> <br> filter->Update();<br> writer->SetFileName( argv[2] );<br> writer->Update();<br><br> return EXIT_SUCCESS;<br>}<br><br><br></div>
</div><br>
</body></html>