[Insight-users] Problem with readers / writers in debug mode

Iván Macía imacia at vicomtech.es
Thu Apr 14 07:27:59 EDT 2005


Hi all,

Im experiencing some trouble with the classes itk::ImageFileReader and
itk::ImageFileWriter.
I get an assertion when trying to update the reader or writer in Debug mode.
This does not 
happen in Release mode or if I declare explicitly an itk::ImageIO derived
object and assign it to the reader / writer.

The following assertion occurs when I try to update the reader in the code
below 

Debug Assertion Failed !
File : dbgdel.cpp
Line : 51
Expression : _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)

The assertion happens in itkImageIOFactory.txx in the CreateImageIO()
function when returning an ImageIOBase::Pointer from the std::list<> . Seems
to be a problem with the std::list<> destruction.

Im running itk-2.0.0 (experienced this problem with older versions too) with
Visual Studio 7.0. Any help would be very appreciated.

Thanks in advance

Iván



// ImageSubstract.cxx
// Substracts two 3D images taken as inputs

#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkSubtractImageFilter.h"

using namespace itk;

int main( int argc, char ** argv )
{

	// Verify the number of parameters in the command line
	if( argc < 4 )
	{
		std::cerr << "Usage: " << std::endl;
		std::cerr << argv[0] << " inputImageFile1 inputImageFile2
outputImageFile " 
			<< std::endl;
		return -1;
	}
	
	typedef float ReaderPixelType;
	typedef short WriterPixelType;
	typedef float InternalPixelType;
	const unsigned int Dimension = 3;
	typedef Image< ReaderPixelType, Dimension > ReaderImageType;
	typedef Image< WriterPixelType, Dimension > WriterImageType;
	typedef Image< InternalPixelType, Dimension > InternalImageType;
	typedef ImageFileReader< ReaderImageType > ReaderType;
	typedef ImageFileWriter< WriterImageType > WriterType;
	typedef SubtractImageFilter< InternalImageType, InternalImageType,
WriterImageType > 
		SubstractFilterType;
	
	ReaderType::Pointer reader1 = ReaderType::New();
	ReaderType::Pointer reader2 = ReaderType::New();
	WriterType::Pointer writer = WriterType::New();
	SubstractFilterType::Pointer substractor =
SubstractFilterType::New();
	
	const char * inputFilename1 = argv[1];
	const char * inputFilename2 = argv[2];
	const char * outputFilename = argv[3];
	
	reader1->SetFileName( inputFilename1 );
	reader2->SetFileName( inputFilename2 );

	try 
  	{ 
    		reader1->Update();
		reader2->Update();
  	} 
  
	catch( itk::ExceptionObject & err ) 
  	{ 
      	std::cout << "ExceptionObject caught !" << std::endl; 
    		std::cout << err << std::endl; 
    		return -1;
  	}
	
	substractor->SetInput1( reader1->GetOutput() );
	substractor->SetInput2( reader2->GetOutput() );

	try 
  	{ 
      	substractor->Update();
	} 
  
	catch( itk::ExceptionObject & err ) 
  	{ 
    		std::cout << "ExceptionObject caught !" << std::endl; 
    		std::cout << err << std::endl; 
    		return -1;
  	}
	
	writer->SetFileName( outputFilename );
	writer->SetInput( substractor->GetOutput() );
	
	try 
	{ 
		writer->Update(); 
	}
 
	catch( itk::ExceptionObject & err ) 
	{ 
		std::cout << "ExceptionObject caught !" << std::endl; 
		std::cout << err << std::endl; 
		return -1;
	}
}

-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.9 - Release Date: 13/04/2005
 



More information about the Insight-users mailing list