[vtkusers] Error messages and no image with vtkImageViewer2

Jan vtk at schreiber2.de
Sun Jun 22 10:12:47 EDT 2008


Hi John,

thank you very much for this information.

I modified the file you sent as attached in 3 sections:

To ensure the usage of unsigned short as pixel type:
///////////  MODIFIED  ///////////
//    typedef itk::RGBPixel< unsigned char > PixelType;
    typedef unsigned char PixelType;
///////////  MODIFIED  ///////////


To use vtkImageShiftScale:
///////////  MODIFIED  ///////////
//    actor->SetInput(vtkImporter->GetOutput());

    vtkImageShiftScale *shiftscalefilter = vtkImageShiftScale::New();
    shiftscalefilter->SetInput( vtkExporter->GetOutput() );
    shiftscalefilter->SetOutputScalarTypeToUnsignedChar ();
    actor->SetInput(shiftscalefilter->GetOutput());
///////////  MODIFIED  ///////////


To use vtkImageViewer2:
///////////  MODIFIED  ///////////
    vtkImageViewer2* imageViewer2 = vtkImageViewer2::New();
//    vtkRenderWindow* renWin = vtkRenderWindow::New();
    vtkRenderWindow* renWin = imageViewer2->GetRenderWindow();
///////////  MODIFIED  ///////////

The resulting messages are exactly the same as in my program plus:
ERROR: In VTK-504/Filtering/vtkDemandDrivenPipeline.cxx, line 710
vtkStreamingDemandDrivenPipeline (0x10170b0): Input port 0 of algorithm 
vtkImageShiftScale(0x10156a0) has 0 connections but is not optional.
The image is not displayed when I use vtkImageViewer2 and/ or 
vtkImageShiftScale.
I also tested all modifications separate which did not help.

Especially with the last part of my modification where I introduce the 
vtkImageViewer2, I am not really sure if it's legal what I am doing 
there. Do you know what the best entry point into VTK is? The VTK User's 
Guide seems not to be available in Germany and I had to let it ship from 
the US...


Thanks,
Jan

P.S.: do you have an explanation why the images that I load/ display 
with the original version of itkReadITKImageShowVTK that you sent are 
shown upside down?



John Eke wrote:
> 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 <mailto:vtkusers-bounces at vtk.org> on 
> behalf of Jan
> > Sent: Wed 6/18/2008 6:22 PM
> > To: vtkusers at vtk.org <mailto: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 --------------
A non-text attachment was scrubbed...
Name: itkReadITKImageShowVTK.cxx
Type: text/x-c++src
Size: 8294 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080622/df178368/attachment.cxx>


More information about the vtkusers mailing list