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

Iván Macía imacia at vicomtech.es
Mon Apr 18 07:15:19 EDT 2005


Hi Luis,

You were right, I was linking with release version of itkCommon because I
had it in the path but I wasn't receiving any warning / error. I find it a
problem that in the project CMake generates the debug and release version of
the common library have the same name (instead of calling them
itkCommond.lib and itkCommon.lib respectively for example). Of course it is
easy to change it manually.

Thank you very much for your help

Iván




> -----Mensaje original-----
> De: Luis Ibanez [mailto:luis.ibanez at kitware.com] 
> Enviado el: domingo, 17 de abril de 2005 23:42
> Para: Iván Macía
> CC: Insight Users
> Asunto: Re: [Insight-users] Problem with readers / writers in 
> debug mode
> 
> 
> 
> Hi Ivan,
> 
> You are probably mixing libraries from two different 
> compilation modes (Debug/Release), this may happen if your 
> have DLLs lying around in your path.
> 
> Didn't you get a warning/error message at the moment
> of linking your executable ?
> 
> If so, please post that message to the list.
> 
> 
>    Regards,
> 
> 
> 
>       Luis
> 
> 
> 
> -----------------------
> Iván Macía wrote:
> 
> > 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 incoming message.
> Checked by AVG Anti-Virus.
> Version: 7.0.308 / Virus Database: 266.9.11 - Release Date: 14/04/2005
>  
> 

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



More information about the Insight-users mailing list