[Insight-users] Race condition in Write ?
Emma Ryan
eryanvtk at yahoo.com
Fri Sep 3 19:33:50 EDT 2010
Hello All,
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.
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.
Thank you,
Emma
#include "itkBinaryThresholdImageFilter.h"
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
int main( int argc, char * argv[] )
{
if( argc < 7 )
{
std::cerr << "Usage: " << argv[0];
std::cerr << " inputImageFile outputImageFile ";
std::cerr << " lowerThreshold upperThreshold ";
std::cerr << " outsideValue insideValue " << std::endl;
return EXIT_FAILURE;
}
typedef unsigned char InputPixelType;
typedef unsigned char OutputPixelType;
typedef itk::Image< InputPixelType, 2 > InputImageType;
typedef itk::Image< OutputPixelType, 2 > OutputImageType;
typedef itk::BinaryThresholdImageFilter<
InputImageType, OutputImageType > FilterType;
typedef itk::ImageFileReader< InputImageType > ReaderType;
typedef itk::ImageFileWriter< OutputImageType > WriterType;
ReaderType::Pointer reader = ReaderType::New();
FilterType::Pointer filter = FilterType::New();
WriterType::Pointer writer = WriterType::New();
writer->SetInput( filter->GetOutput() );
reader->SetFileName( argv[1] );
filter->SetInput( reader->GetOutput() );
const OutputPixelType outsideValue = atoi( argv[5] );
const OutputPixelType insideValue = atoi( argv[6] );
filter->SetOutsideValue( outsideValue );
filter->SetInsideValue( insideValue );
const InputPixelType lowerThreshold = atoi( argv[3] );
const InputPixelType upperThreshold = atoi( argv[4] );
filter->SetLowerThreshold( lowerThreshold );
filter->SetUpperThreshold( upperThreshold );
filter->Update();
writer->SetFileName( argv[2] );
writer->Update();
return EXIT_SUCCESS;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100903/beb8349c/attachment.htm>
More information about the Insight-users
mailing list