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

syssboxx-reg at yahoo.fr syssboxx-reg at yahoo.fr
Mon May 30 13:22:14 EDT 2005


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();

renwin->Delete();

ren->Delete();

actor->Delete();

return( 0 );

}

Any advices?
 
Stanislava Ivanova

Karthik Krishnan <Karthik.Krishnan at kitware.com> a écrit :
Please post your CMakeLists.txt file and if possible a minimal example. 
It looks like you are not linking against some VTK libraries. If you are 
not certain, for now add all the libraries to see if it compiles
TARGET_LINK_LIBRARIES( ProjectFoo vtkIO vtkCommon vtkHybrid vtkRendering 
vtkImaging ITKCommon ITKBasicFilters ITKNumerics ITKAlgorithms ITKIO)

thanks
karthik

syssboxx-reg at yahoo.fr wrote:

>Hi Luis;
>
>I was thinking that the cause of my linking problems
>when using itkImageToVTKImageFilter was my
>installation.Now i reinstalled VTK and i try to build 
>all above Visual Studio 7.NET 2003 but it's the same.
>I really can't find the problem.Is anybody else have a
>problems with itkImageToVTKImageFilter?Or not could
>you help me to make it work correctly?
>
> 
>--- Luis Ibanez a écrit:
> 
>
>>Hi Stanislava,
>>
>>You are missing to link with some VTK libraries.
>>
>>Please post the CMakeLists.txt file of your project
>>and let us konw what version of VTK you are using.
>>
>>
>> Thanks
>>
>>
>> Luis
>>
>>
>>
>>-----------------------------------
>>syssboxx-reg at yahoo.fr wrote:
>>
>> 
>>
>>>Hi all,
>>>I'm not very experienced with both itk and vtk,for
>>> 
>>>
>>the moment i was 
>> 
>>
>>>making some processing with itk and saving the
>>> 
>>>
>>output to a file.Now I 
>> 
>>
>>>want to make my algorithme with 3d images so I try
>>> 
>>>
>>to use vtk.I listened 
>> 
>>
>>>some posting about itkImageToVTKImageFilter and
>>> 
>>>
>>the ways to connect itk 
>> 
>>
>>>and vtk ( i use one example which read,segment a
>>> 
>>>
>>2d image,write it and 
>> 
>>
>>>show it in vtk . Now my program find the header
>>> 
>>>
>>but gives me some 
>> 
>>
>>>errors.Could someone tell me how to solve this
>>> 
>>>
>>problem please. I list 
>> 
>>
>>>bellow the errors:
>>>Thanks
>>> 
>>>--------------------Configuration: segex - Win32 
>>>RelWithDebInfo--------------------
>>>Compiling...
>>>segex.cpp.cxx
>>>Linking...
>>> Creating library RelWithDebInfo/segex.lib and
>>> 
>>>
>>object 
>> 
>>
>>>RelWithDebInfo/segex.exp
>>>segex.cpp.obj : error LNK2001: unresolved external
>>> 
>>>
>>symbol "public: 
>> 
>>
>>>static class vtkInteractorStyleImage * __cdecl 
>>>vtkInteractorStyleImage::New(void)" 
>>>(?New at vtkInteractorStyleImage@@SAPAV1 at XZ 
>>>)
>>>segex.cpp.obj : error LNK2001: unresolved external
>>> 
>>>
>>symbol "public: void 
>> 
>>
>>>__thiscall
>>> 
>>>
>>vtkRenderWindowInteractor::SetRenderWindow(class 
>> 
>>
>>>vtkRenderWindow *)" 
>>>
>>> 
>>>
>(?SetRenderWindow at vtkRenderWindowInteractor@@QAEXPAVvtkRenderWindow@@@Z
> 
>
>)
> 
>
>>>segex.cpp.obj : error LNK2001: unresolved external
>>> 
>>>
>>symbol "public: 
>> 
>>
>>>static class vtkRenderWindowInteractor * __cdecl 
>>>vtkRenderWindowInteractor::New(void)" 
>>>(?New at vtkRenderWindowInteractor@@SAPAV1 at XZ 
>>>
>>> 
>>>
>>)
>> 
>>
>>>segex.cpp.obj : error LNK2001: unresolved external
>>> 
>>>
>>symbol "public: 
>> 
>>
>>>static class vtkRenderWindow * __cdecl
>>> 
>>>
>>vtkRenderWindow::New(void)" 
>> 
>>
>>>(?New at vtkRenderWindow@@SAPAV1 at XZ
>>> 
>>>
>>)
>> 
>>
>>>segex.cpp.obj : error LNK2001: unresolved external
>>> 
>>>
>>symbol "public: 
>> 
>>
>>>static class vtkRenderer * __cdecl
>>> 
>>>
>>vtkRenderer::New(void)" 
>> 
>>
>>>(?New at vtkRenderer@@SAPAV1 at XZ
>>> 
>>>
>>)
>> 
>>
>>>segex.cpp.obj : error LNK2001: unresolved external
>>> 
>>>
>>symbol "public: 
>> 
>>
>>>static class vtkImageActor * __cdecl
>>> 
>>>
>>vtkImageActor::New(void)" 
>> 
>>
>>>(?New at vtkImageActor@@SAPAV1 at XZ
>>> 
>>>
>>)
>> 
>>
>>>RelWithDebInfo/segex.exe : fatal error LNK1120: 6
>>> 
>>>
>>unresolved externals
>> 
>>
>>>Error executing link.exe.
>>>ALL_BUILD - 7 error(s), 0 warning(s)
>>> 
>>>Stanislava Ivanova
>>>
>>>
>>> 
>>>
>------------------------------------------------------------------------
> 
>
>>>Découvrez le nouveau Yahoo! Mail : 1 Go d'espace
>>> 
>>>
>>de stockage pour vos 
>> 
>>
>>>mails, photos et vidéos !
>>>Créez votre Yahoo! Mail 
>>>
>>> 
>>>
>
> 
>
>>>
>>>
>>> 
>>>
>------------------------------------------------------------------------
> 
>
>>>_______________________________________________
>>>Insight-users mailing list
>>>Insight-users at itk.org
>>>http://www.itk.org/mailman/listinfo/insight-users
>>> 
>>>
>>
>>
>> 
>>
>
>
> 
> 
> 
>___________________________________________________________________________
>Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger 
>Téléchargez cette version sur http://fr.messenger.yahoo.com
>_______________________________________________
>Insight-users mailing list
>Insight-users at itk.org
>http://www.itk.org/mailman/listinfo/insight-users
>
> 
>

		
---------------------------------
 Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger
 Téléchargez le ici ! 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20050530/38db30b5/attachment-0001.htm


More information about the Insight-users mailing list