[Insight-users] Runtime error while connecting itk with vtk

Sotiris Dimopoulos vtksot_dimopoulos at yahoo.gr
Mon Dec 20 12:04:59 EST 2004


Hi to all!

I started using itk 1.8( xp,visual studio 6) few days
ago so i don't have experience with it..i try to
connect vtk with itk in my project (read images with
vtk,do the image processing with itk and do the
visualization with vtk again),so when i try to test
the procedure vtk -> itk -> vtk,described in an
example i found (see at the end of the mail), although
the compile-build process its flowless(0 warnings,0
errors) when i try to execute the "exe" file i get a
"runtime error"  and the  message "abnormal
termination"...

Have you got an idea of what might be?  

I'm sending you the example that i used as a guide
which makes me the same error when entering to the itk
pipeline (the first image is displayed ok, but when i
close the first and i'm about to see the other two i
get the message i decribed above)  :

#include "itkImage.h"
#include "itkVTKImageExport.h"
#include "itkVTKImageImport.h"
#include "itkCurvatureFlowImageFilter.h" 
#include "vtkImageImport.h"
#include "vtkImageExport.h"
#include "vtkImageShiftScale.h"
#include "vtkImageNoiseSource.h"
#include "vtkImageActor.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h" 
#include "vtk2itk2vtk.h"

int main()

{  

  // VTK pipeline.

  
  vtkImageNoiseSource* source =
vtkImageNoiseSource::New();

  source->SetWholeExtent(0, 255, 0, 255, 0, 0);

  source->SetMinimum(0);

  source->SetMaximum(1); 


  // Create a vtkImageShiftScale to convert the
floating point image

  // to an unsigned char image.  

  vtkImageShiftScale* shifter =
vtkImageShiftScale::New();

  shifter->SetInput(source->GetOutput());

  shifter->SetScale(256);

  shifter->SetOutputScalarTypeToUnsignedChar(); 


  // Create a vtkImageActor to help render the image. 
Connect it to

  // the vtkImageShiftScale instance.

  vtkImageActor* actor = vtkImageActor::New();

  actor->SetInput(shifter->GetOutput());

  

  // Create a renderer, render window, and render
window interactor to

  // display the results.

  vtkRenderer* renderer = vtkRenderer::New();

  vtkRenderWindow* renWin = vtkRenderWindow::New();

  vtkRenderWindowInteractor* iren =
vtkRenderWindowInteractor::New();

  

  renWin->SetSize(500, 500);

  renWin->AddRenderer(renderer);

  iren->SetRenderWindow(renWin);

  

  // Add the vtkImageActor to the renderer for
display.

  renderer->AddActor(actor);

  renderer->SetBackground(0.4392, 0.5020, 0.5647); 


  // Bring up the render window and begin interaction.

  renWin->Render();

  iren->Start();

  
// Create a vtkExport object.

  vtkImageExport* vtkExporter = vtkImageExport::New();

  vtkExporter->SetInput(source->GetOutput());

  

   // VTK to ITK pipeline connection.

  

  typedef itk::Image<float, 2> ImageType;

  typedef itk::VTKImageImport<ImageType>
ImageImportType;

  ImageImportType::Pointer itkImporter =
ImageImportType::New();

  ConnectPipelines(vtkExporter, itkImporter);

  

  // ITK pipeline.

  

  typedef itk::CurvatureFlowImageFilter<ImageType,
ImageType> DenoiserType;

  

  // Create the itk::CurvatureFlowImageFilter to
smooth the source data.

  DenoiserType::Pointer denoiser =
DenoiserType::New();

  denoiser->SetInput(itkImporter->GetOutput());

  denoiser->SetTimeStep(0.15);

  denoiser->SetNumberOfIterations(8); 


 
  // ITK to VTK pipeline connection.

   

  typedef itk::VTKImageExport<ImageType>
ImageExportType;

  

// Create the itk::VTKImageExport instance and connect
it to the

  // itk::CurvatureFlowImageFilter.

  ImageExportType::Pointer itkExporter =
ImageExportType::New();

  itkExporter->SetInput(denoiser->GetOutput());

  

  // Create the vtkImageImport and connect it to the

  // itk::VTKImageExport instance.

  vtkImageImport* vtkImporter = vtkImageImport::New();
 

  ConnectPipelines(itkExporter, vtkImporter);

  

  // VTK pipeline.

 


  // Convert the floating point image to an unsigned
char image.  

  shifter->SetInput(vtkImporter->GetOutput());

  shifter->SetScale(256);

  shifter->SetOutputScalarTypeToUnsignedChar(); 


  // Update the input to actor. 

  actor->SetInput(shifter->GetOutput());

  iren->Start(); 


  // After last interaction is quit, modifiy the ITK
pipeline and

  // begin interaction again.  The user will see the
ITK pipeline

  // re-execute due only to the update request through
the VTK

  // pipeline.

  source->SetMinimum(0.5);

  iren->Start();

  

  // VTK does not use smart pointers, so we must clean
up its pipeline

  // explicitly.

  iren->Delete();

  renWin->Delete();

  renderer->Delete();

  actor->Delete();

  shifter->Delete();

  vtkImporter->Delete();

  source->Delete();

  vtkExporter->Delete();

  

  return 0;
  }


Thanks


____________________________________________________________
Do You Yahoo!?
Αποκτήστε τη δωρεάν @yahoo.gr διεύθυνση σας στο http://www.otenet.gr


More information about the Insight-users mailing list