[vtkusers] Error messages and no image with vtkImageViewer2
Jan
vtk at schreiber2.de
Wed Jun 18 18:22:16 EDT 2008
Hi,
I am writing a little QT application using ITK and VTK, trying to use
vtkIMageViewer2.
During startup, I get the following error messages:
ERROR: In VTK-504/Filtering/vtkDemandDrivenPipeline.cxx, line 710
vtkStreamingDemandDrivenPipeline (0x11b8570): Input port 0 of algorithm
vtkImageMapToWindowLevelColors(0x118dc50) has 0 connections but is not
optional.
ERROR: In VTK-504/Rendering/vtkImageActor.cxx, line 182
vtkOpenGLImageActor (0x11bfaf0): This filter requires unsigned char
scalars as input
And the view keeps blank
=============================================================
Code:
=============================================================
ViewingWidget.h:
...
QVTKWidget _view;
...
ViewingWidget.cpp:
...
ViewingWidget::ViewingWidget( const char* name) :
QWidget()
{
_imageViewer = vtkImageViewer2::New();
_view.setParent( this );
_view.SetRenderWindow( _imageViewer->GetRenderWindow() );
_imageViewer->SetupInteractor(
_view.GetRenderWindow()->GetInteractor() );
_imageViewer->SetColorLevel( 100 );
_imageViewer->SetColorWindow( 256 );
}
...
loading the image comes later when pressing a button.
typedef itk::Image< unsigned char, 3 > ImageType;
typedef itk::ImageSeriesReader< ImageType > ReaderType;
typedef itk::ImageToVTKImageFilter< ImageType > FilterType;
ImageType::Pointer image;
ReaderType::Pointer reader = ReaderType::New();
FilterType::Pointer itk2vtk;
...
reader->SetFileNames( names );
reader->Update();
image = reader->GetOutput();
itk2vtk->SetInput( image );
_imageViewer->SetInput( itk2vtk->GetOutput() );
=============================================================
when I use
vtkPNGReader* reader = vtkPNGReader::New();
reader->SetFileName( "image.png" );
_imageViewer->SetInputConnection( reader->GetOutputPort() );
it shows me a grayscale pattern that does not really look like the input
image.
=============================================================
It would be great if you could give me a hint how to properly use
vtkImageViewer2.
Thanks,
Jan
VTK: 5.0.4
ITK: 3.4.0
QT: 4.3
gcc: 4.2.1 (SUSE Linux)
OpenSuSE 10.3 64bit
More information about the vtkusers
mailing list