[Insight-users] Connecting Output from vtkWin32VideoSource to ITK
PeterW
p.worel at ast-jena.de
Tue Oct 20 06:33:00 EDT 2009
Hello,
I'm new in using ITK and VTK. I'm using vtkWin32VideoSource to grab images
from a framegrabber and I want to use ITK filters on these images. The
problem is to get ITK to work with VTK-images. I tried different approaches
like the "itkVTKImageToImageFilter.h" /"itkImageToVTKImageFilter.h" or the
"vtkKWImage.h"/"vtkKWImageIO.h" but I didn't get ITK to work with the input
from VTK. I testet a few
things like...
//WindowInteractor
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
//Bild einladen
//vtkJPEGReader *reader = vtkJPEGReader::New();
vtkBMPReader *reader = vtkBMPReader::New();
reader->SetFileName("D:/Tests/ITK+VTK-Test1/src/test24.bmp");
vtkImageCast *caster = vtkImageCast::New();
caster->SetInput(reader->GetOutput());
caster->SetOutputScalarTypeToFloat();
caster->Modified();
caster->Update();
//ITK-Part
typedef itk::Image<float, 2> ImageType;
typedef itk::VTKImageToImageFilter<ImageType> InputFilterType;
typedef itk::ImageToVTKImageFilter<ImageType> OutputFilterType;
//typedef itk::GradientMagnitudeImageFilter<ImageType,ImageType>
FilterType;
InputFilterType::Pointer vtktoitk = InputFilterType::New();
OutputFilterType::Pointer itktovtk = OutputFilterType::New();
//FilterType::Pointer itkfilter1 = FilterType::New();
//VTK-Import
vtktoitk->SetInput(caster->GetOutput());
vtktoitk->GetImporter()->Update();
vtktoitk->Update();
//ITK-Filter1
//itkfilter1->SetInput(vtktoitk->GetOutput());
//itkfilter1->Update();
//VTK-Export
itktovtk->SetInput(vtktoitk->GetOutput());
itktovtk->Update();
//VTK-Part2
//Image-Viewer
vtkImageViewer *viewer = vtkImageViewer::New();
viewer->SetInput(itktovtk->GetOutput());
viewer->SetupInteractor(iren);
viewer->SetColorWindow(255);
viewer->SetColorLevel(128);
viewer->Render();
//Anzeigen
iren->Initialize();
iren->Start();
//Aufräumen
reader->Delete();
viewer->Delete();
iren->Delete();
...but I alway get exceptions in connection to itkLightObject. To read a
file via ITK and manage the ouput with VTK is no problem but I want to
achieve to use the input from vtkWin32VideoSource and I don't know a way to
get ITK to work with a framegrabber, so I have to use VTK-input. Could be
that I make a few poor mistakes, but I don't know how to get on with the
problem. So can someone please help me?
Thanks in avanced.
Peter
PS: Please excuse my poor English.
--
View this message in context: http://n2.nabble.com/Connecting-Output-from-vtkWin32VideoSource-to-ITK-tp3857870p3857870.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.
More information about the Insight-users
mailing list