[vtkusers] Error messages and no image with vtkImageViewer2

John Eke tonee47 at yahoo.com
Thu Jun 19 23:58:45 EDT 2008


Ok, so the first error I believe is an error with the pipeline. Sometimes its jacked up trying to connect ITK, VTK, and Qt pipelines. I attached an example that comes with ITK that shows a proper way to connect ITK and VTK rendering pipelines.

To solve the second error, try something like this:

#include "vtkImageShiftScale.h"

...
...

    vtkImageShiftScale *shiftscalefilter = vtkImageShiftScale::New();
    shiftscalefilter->SetInput(itk2vtk->GetOutput());
    shiftscalefilter->SetOutputScalarTypeToUnsignedChar ();
    _imageViewer->SetInputConnection(shiftscalefilter->GetOutputPort());

.... etc

See if the error still occurs. Let me know how it turns out.

- John


----- Original Message ----
From: Jan <vtk at schreiber2.de>
To: vtkusers at vtk.org
Sent: Thursday, June 19, 2008 6:20:34 PM
Subject: Re: [vtkusers] Error messages and no image with vtkImageViewer2

Hi John,

thanks a lot for your quick reply.

I have now changed it to
     typedef itk::Image< unsigned char, 2 > ImageType;
     typedef itk::ImageFileReader< ImageType > ReaderType;

Unfortunately, nothing has changed. The second error message 
("vtkOpenGLImageActor (0x1173a00): This filter requires unsigned char 
scalars as input") already appears at startup before I initiate loading 
the image...

Do you have any other ideas that could solve the issue?

Thanks,
Jan


John Eke wrote:
> 
> 
> Hi Jan,
> 
> Have you tried the ITK+VTK connection reading just one image file for 
> now? see if you can make that work before you try reading several 
> slices. If you read in the image as <unsigned char, 2> the you shouldn't 
> get the second error message anymore.
> 
> - John
> 
> 
> -----Original Message-----
> From: vtkusers-bounces at vtk.org on behalf of Jan
> Sent: Wed 6/18/2008 6:22 PM
> To: vtkusers at vtk.org
> Subject: [vtkusers] Error messages and no image with vtkImageViewer2
> 
> 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
> 
> 
> 
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: 
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> 

_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080619/cff813b9/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: itkReadITKImageShowVTK.cxx
Type: text/x-c++src
Size: 7610 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080619/cff813b9/attachment.cxx>


More information about the vtkusers mailing list