[vtkusers] how to connect ITK to VTK?
Serhat Guneyli
serhatguneyli at yahoo.com
Thu Jul 8 03:40:34 EDT 2004
Hi vtk users,
I joined the itk & vtk family about a few weeks ago.
Up to now, i didn't write any meesages, but I tried to
find the answers to my questions by checking the
discussions you had in the past on this email list.. I
think, now i need some help.. It would be very nice,
if anyone can answer my question.
So, i am trying to connect ITK and VTK. I want to
visualize the output of an ITK filter via VTK. I am
using itkImageToVTKImageFilter.h class for it, and my
sample is an .png image. I added almost all of the
libs but still couldn't solve the problem.
Here down is my code and the error messages I get.
Thanks in advance,
Serhat Guneyli
// Define input image
#ifdef WIN32
#include "..\\..\\data\\Data.h"
#else
#include "../../data/Data.h"
#endif
// ITK
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkGradientMagnitudeImageFilter.h"
// ITK to VTK
#include "itkImageToVTKImageFilter.h"
// VTK
#include "vtkImageViewer.h"
#include "vtkRenderWindowInteractor.h"
// Standard libs
#include <iostream>
int main()
{
// Define image
const unsigned int Dimension = 2;
typedef unsigned short PixelType;
typedef itk::Image< PixelType, Dimension > ImageType;
// Read Image from file
typedef itk::ImageFileReader< ImageType >
FileReaderType;
FileReaderType::Pointer pReader =
FileReaderType::New();
pReader->SetFileName( INPUT_IMAGE_FILE );
/*
* Create ITK image (gradient magnitude, page 126)
*/
typedef itk::GradientMagnitudeImageFilter< ImageType,
ImageType > GradMagFilterType;
GradMagFilterType::Pointer pFilter =
GradMagFilterType::New();
pFilter->SetInput( pReader->GetOutput() );
/*
* ITK -> VTK
*/
typedef itk::ImageToVTKImageFilter< ImageType >
ConnectorType;
ConnectorType::Pointer pConnector;
pConnector->SetInput( pFilter->GetOutput() );
vtkRenderWindowInteractor *pInteractor =
vtkRenderWindowInteractor::New();
vtkImageViewer *pViewer = vtkImageViewer::New();
pViewer->SetInput( pConnector->GetOutput() );
pViewer->SetupInteractor( pInteractor );
pViewer->SetColorWindow( 255 );
pViewer->SetColorLevel( 128 );
pViewer->Render();
pInteractor->Start();
return 0;
}
and the errors:
Gradients2.obj : error LNK2001: unresolved external
symbol "public: class vtkImageData * __thiscall
itk::ImageToVTKImageFilter<class itk::Image<unsigned
short,2> >::GetOutput(void)const "
(?GetOutput@?$ImageToVTKImageFilter at V?$Image at G$01 at itk@@@itk@@
QBEPAVvtkImageData@@XZ)
Gradients2.obj : error LNK2001: unresolved external
symbol "public: void __thiscall
itk::ImageToVTKImageFilter<class itk::Image<unsigned
short,2> >::SetInput(class itk::Image<unsigned
short,2> const *)"
(?SetInput@?$ImageToVTKImageFilter at V?$Image at G$
01 at itk@@@itk@@QAEXPBV?$Image at G$01 at 2@@Z)
Debug/Gradients2.exe : fatal error LNK1120: 2
unresolved externals
__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail
More information about the vtkusers
mailing list