[Insight-users] Linking error with use of itkImageToVTKImageFilter ?

syssboxx-reg at yahoo.fr syssboxx-reg at yahoo.fr
Tue May 31 03:42:14 EDT 2005


Hi Karthik,
It seems that vtkRendering was commented as you
said.Now It works.Thank you very much.

Stanislava Ivanova


--- Karthik Krishnan <Karthik.Krishnan at kitware.com> a
écrit :

> I can see from the linker errors that you are
> clearly not linking 
> against vtkRendering.
> 
> Are you sure that the # in the CMakeLists.txt is not
> commenting it out.. 
> The # comments out everything on that line
> 
> thanks
> karthik
> 
> syssboxx-reg at yahoo.fr wrote:
> 
> > Hi
> >  
> > Here is my CMakelist.txt:
> >  
> > PROJECT( segex )
> >
> > # Find the ITK and VTK libraries
> >  
> > FIND_PACKAGE(ITK)
> > IF(ITK_FOUND)
> >   
> >  INCLUDE(${ITK_USE_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 (${VTK_USE_FILE})
> > ELSE(VTK_FOUND)
> >   
> >  MESSAGE(FATAL_ERROR
> >        "Cannot build without ITK.  Please set
> VTK_DIR.")
> > ENDIF(VTK_FOUND)
> >  
> > ADD_EXECUTABLE(segex segex.cpp)
> >  
> > # Optionally use vtkPatented libs (for
> Contouring/Marching Cubes)
> >  
> > TARGET_LINK_LIBRARIES(segex  ITKCommon ITKIO
> ITKBasicFilters vtkCommon 
> > vtkImaging vtkGraphics vtkIO vtkFiltering
> #vtkPatented # vtkHybrid 
> > vtkRendering))
> >  
> > and here is my program :
> >  
> >
> > #include <string>
> >
> > #include <itkImage.h>
> >
> > #include <itkImageFileReader.h>
> >
> > #include <itkImageFileWriter.h>
> >
> > #include <itkFixedArray.h>
> >
> > #include <itkFlipImageFilter.h>
> >
> > #include <itkDiscreteGaussianImageFilter.h>
> >
> > #include <itkThresholdImageFilter.h>
> >
> > #include <vtkImageShiftScale.h>
> >
> > #include <vtkImageActor.h>
> >
> > #include <vtkRenderer.h>
> >
> > #include <vtkRenderWindow.h>
> >
> > #include <vtkRenderWindowInteractor.h>
> >
> > #include <vtkInteractorStyleImage.h>
> >
> > #include "itkImageToVTKImageFilter.h"
> >
> > int main( int argc, char* argv[] ) {
> >
> > std::string filename( "images/stem.jpg" );
> >
> > int threshold = 100;
> >
> > if ( argc > 1 ) {
> >
> > std::string ftmp( argv[1] );
> >
> > filename = ftmp;
> >
> > }
> >
> > if ( argc > 2 ){
> >
> > threshold = atoi( argv[2] );
> >
> > }
> >
> > const unsigned int TwoD = 2;
> >
> > typedef unsigned char ImagePixelType;
> >
> > typedef itk::Image< ImagePixelType, TwoD >
> InputImageType;
> >
> >  
> >
> > typedef itk::ImageFileReader< InputImageType >
> ReaderType;
> >
> > ReaderType::Pointer reader = ReaderType::New();
> >
> > reader->SetFileName( filename.c_str() );
> >
> > reader->Update();
> >
> >  
> >
> > typedef itk::ThresholdImageFilter<
> >
> > InputImageType > SegmentFilterType;
> >
> > SegmentFilterType::Pointer segmenter =
> SegmentFilterType::New();
> >
> > segmenter->SetInput( reader->GetOutput() );
> >
> > segmenter->SetOutsideValue( 0 );
> >
> > segmenter->ThresholdBelow( threshold );
> >
> > segmenter->Update();
> >
> >  
> >
> > typedef itk::ImageFileWriter< InputImageType >
> WriterType;
> >
> > WriterType::Pointer writer = WriterType::New();
> >
> > writer->SetInput( segmenter->GetOutput() );
> >
> > writer->SetFileName( "images/stem_out.jpg" );
> >
> > writer->Update();
> >
> >  
> >
> > // Show segmentation result (connect ITK -> VTK)
> >
> > typedef itk::ImageToVTKImageFilter< InputImageType
> > ImageToVTKType;
> >
> > ImageToVTKType::Pointer bridge =
> ImageToVTKType::New();
> >
> > bridge->SetInput( segmenter->GetOutput() );
> >
> > vtkImageActor* actor = vtkImageActor::New();
> >
> > actor->SetInput( bridge->GetOutput() );
> >
> > actor->InterpolateOff();
> >
> > vtkRenderer* ren = vtkRenderer::New();
> >
> > ren->SetBackground( 0.4392, 0.5020, 0.5647 );
> >
> > ren->AddActor( actor );
> >
> > vtkRenderWindow* renwin = vtkRenderWindow::New();
> >
> > renwin->AddRenderer( ren );
> >
> > vtkRenderWindowInteractor* iren =
> vtkRenderWindowInteractor::New();
> >
> > iren->SetRenderWindow( renwin );
> >
> > iren->Initialize();
> >
> > vtkInteractorStyleImage* style =
> vtkInteractorStyleImage::New();
> >
> > iren->SetInteractorStyle( style );
> >
> >  
> >
> > iren->Start();
> >
> > style->Delete();
> >
> > iren->Delete();
> 
=== message truncated ===



	
	
		
___________________________________________________________________________
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger 
Téléchargez cette version sur http://fr.messenger.yahoo.com


More information about the Insight-users mailing list