[Insight-users] Help with the template matching : : Problemconnecting VTK and ITK

Luis Ibanez luis.ibanez at kitware.com
Mon, 01 Mar 2004 23:02:10 -0500


Hi Longfei,

Thanks for the additional details.

This message sounds quite strange,
are you sure that this is the "exact" error message ?

Could you please post it exactly as it appears ?

What is your platform, compiler, versions of VTK and ITK ?

One typical suspect, if you are in MS-Windows, is that you
may be mixing Debug and Release libraries which results
in run-time instabilities.


Please let us know more details about your problem.


Thanks



   Luis


---------------------

Longfei Cong wrote:

> HI Luis Ibanez,
>         I have compile the program successfully ,but it  throwing an exception "the initialization of the program is failed" when I execute it. there are no line of the codes in the main function is executed.
>   Thanks!
> 
> 
>>Hi Longfei,
>>
>>Can you please give us more information on what you
>>meant by "the initialization of the program is failed"  ?
>>
>>Is it producing a segmentation fault ?
>>Is it throwing an exception  ?
>>Is it producing incorrect output ?
>>
>>Does it produces any error message ?
>>
>>Did you tried adding a try/catch block around your code ?
>>
>>
>>
>>Thanks
>>
>>
>>  Luis
>>
>>
>>----
>>
>>PS: Please don't reuse 'subject' lines from unrelated emails.
>>That's confusing when people search in the archives of the mailing list.
>>---------------------
>>Longfei Cong wrote:
>>
>>
>>>Hi luis.ibanez
>>>       i have used ITk for some weeks, which gived me a lot of help. But now I want to link the ITk with VTk. i try to compile give in the net which transfer the image in itk to vtk. 
>>>The initialization of the program is failed, while the comile is OK! The code is given as below.        
>>>	best regards,
>>>
>>>
>>>file "CMakeLists.txt "
>>>
>>>PROJECT(myProject)   
>>>FIND_PACKAGE ( ITK)
>>> IF ( ITK_FOUND)
>>>    INCLUDE( ${USE_ITK_FILE} )
>>>    ELSE(ITK_FOUND)
>>>       MESSAGE(FATAL_ERROR
>>>           "Cannot build without ITK.  Please set ITK_DIR.")    
>>>  ENDIF( ITK_FOUND)      
>>> FIND_PACKAGE ( VTK)
>>>  IF ( VTK_FOUND)
>>>    INCLUDE( ${USE_VTK_FILE} )  
>>> ELSE(VTK_FOUND)
>>>       MESSAGE(FATAL_ERROR
>>>           "Cannot build without VTK.  Please set VTK_DIR.")       
>>>  ENDIF( VTK_FOUND)
>>>  
>>>INCLUDE_DIRECTORIES(${myProject_SOURCE_DIR})            
>>>ADD_EXECUTABLE( myProject myProject.cxx)
>>>
>>>TARGET_LINK_LIBRARIES ( myProject ITKBasicFilters ITKCommon ITKIO vtkRendering vtkGraphics vtkHybrid vtkImaging vtkIO vtkFiltering vtkCommon)
>>>//******************************
>>>file "myProject.cxx"
>>>#include "itkImage.h"
>>>
>>>#include "itkImageFileReader.h"
>>>#include "itkImageToVTKImageFilter.h"
>>>#include "vtkImageViewer.h"
>>>#include "vtkRenderWindowInteractor.h"
>>>
>>>
>>>int main()
>>> {
>>>	char dataru[]="FatMRISlice.png";
>>>typedef itk::Image<unsigned short,3> ImageType;
>>>typedef itk::ImageFileReader<ImageType> ReaderType;
>>>typedef itk::ImageToVTKImageFilter<ImageType> ConnectorType;
>>>
>>>ReaderType::Pointer reader= ReaderType::New();
>>>
>>>ConnectorType::Pointer connector= ConnectorType::New();
>>>reader->SetFileName( dataru);
>>>connector->SetInput( reader->GetOutput() );
>>>vtkImageViewer *viewer= vtkImageViewer::New();
>>>vtkRenderWindowInteractor* renderWindowInteractor= vtkRenderWindowInteractor::New();
>>>viewer->SetupInteractor( renderWindowInteractor);
>>>viewer->SetInput( connector->GetOutput() );
>>>viewer->Render();
>>>viewer->SetColorWindow( 255);
>>>viewer->SetColorLevel( 128);
>>>renderWindowInteractor->Start();
>>>return 0;
>>>}
>>>
>>>    
>>> 				
>>>
>>>        Longfei Cong
>>>        lfcong at nlpr.ia.ac.cn
>>>          2004-03-01
>>>
>>>
>>>
>>>
> 
> 
> 
> 
> 
>