<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:verdana,helvetica,sans-serif;font-size:10pt"><div style="font-family: verdana,helvetica,sans-serif; font-size: 10pt;">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.<br><br>To solve the second error, try something like this:<br><br>#include "vtkImageShiftScale.h"<br><br>...<br>...<br><br> vtkImageShiftScale *shiftscalefilter = vtkImageShiftScale::New();<br> shiftscalefilter->SetInput(itk2vtk->GetOutput());<br> shiftscalefilter->SetOutputScalarTypeToUnsignedChar ();<br> _imageViewer->SetInputConnection(shiftscalefilter->GetOutputPort());<br><br>.... etc<br><br>See if the
error still occurs. Let me know how it turns out.<br><br>- John<br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">----- Original Message ----<br>From: Jan <vtk@schreiber2.de><br>To: vtkusers@vtk.org<br>Sent: Thursday, June 19, 2008 6:20:34 PM<br>Subject: Re: [vtkusers] Error messages and no image with vtkImageViewer2<br><br>
Hi John,<br><br>thanks a lot for your quick reply.<br><br>I have now changed it to<br> typedef itk::Image< unsigned char, 2 > ImageType;<br> typedef itk::ImageFileReader< ImageType > ReaderType;<br><br>Unfortunately, nothing has changed. The second error message <br>("vtkOpenGLImageActor (0x1173a00): This filter requires unsigned char <br>scalars as input") already appears at startup before I initiate loading <br>the image...<br><br>Do you have any other ideas that could solve the issue?<br><br>Thanks,<br>Jan<br><br><br>John Eke wrote:<br>> <br>> <br>> Hi Jan,<br>> <br>> Have you tried the ITK+VTK connection reading just one image file for <br>> now? see if you can make that work before you try reading several <br>> slices. If you read in the image as <unsigned char, 2> the you shouldn't <br>> get the second error message anymore.<br>> <br>> - John<br>> <br>> <br>>
-----Original Message-----<br>> From: <a ymailto="mailto:vtkusers-bounces@vtk.org" href="mailto:vtkusers-bounces@vtk.org">vtkusers-bounces@vtk.org</a> on behalf of Jan<br>> Sent: Wed 6/18/2008 6:22 PM<br>> To: <a ymailto="mailto:vtkusers@vtk.org" href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a><br>> Subject: [vtkusers] Error messages and no image with vtkImageViewer2<br>> <br>> Hi,<br>> <br>> I am writing a little QT application using ITK and VTK, trying to use<br>> vtkIMageViewer2.<br>> <br>> During startup, I get the following error messages:<br>> <br>> ERROR: In VTK-504/Filtering/vtkDemandDrivenPipeline.cxx, line 710<br>> vtkStreamingDemandDrivenPipeline (0x11b8570): Input port 0 of algorithm<br>> vtkImageMapToWindowLevelColors(0x118dc50) has 0 connections but is not<br>> optional.<br>> <br>> ERROR: In VTK-504/Rendering/vtkImageActor.cxx, line 182<br>> vtkOpenGLImageActor (0x11bfaf0): This
filter requires unsigned char<br>> scalars as input<br>> <br>> And the view keeps blank<br>> <br>> <br>> =============================================================<br>> Code:<br>> =============================================================<br>> ViewingWidget.h:<br>> ...<br>> QVTKWidget _view;<br>> ...<br>> <br>> ViewingWidget.cpp:<br>> ...<br>> ViewingWidget::ViewingWidget( const char* name) :<br>> QWidget()<br>> {<br>> _imageViewer = vtkImageViewer2::New();<br>> _view.setParent( this );<br>> _view.SetRenderWindow( _imageViewer->GetRenderWindow() );<br>> _imageViewer->SetupInteractor(<br>> _view.GetRenderWindow()->GetInteractor() );<br>> _imageViewer->SetColorLevel( 100 );<br>> _imageViewer->SetColorWindow( 256 );<br>>
}<br>> ...<br>> <br>> loading the image comes later when pressing a button.<br>> <br>> typedef itk::Image< unsigned char, 3 > ImageType;<br>> typedef itk::ImageSeriesReader< ImageType > ReaderType;<br>> typedef itk::ImageToVTKImageFilter< ImageType > FilterType;<br>> <br>> ImageType::Pointer image;<br>> ReaderType::Pointer reader = ReaderType::New();<br>> FilterType::Pointer itk2vtk;<br>> ...<br>> reader->SetFileNames( names );<br>> reader->Update();<br>> image = reader->GetOutput();<br>> <br>> itk2vtk->SetInput( image );<br>> _imageViewer->SetInput( itk2vtk->GetOutput() );<br>> =============================================================<br>> <br>> when I use<br>> <br>> vtkPNGReader* reader = vtkPNGReader::New();<br>> reader->SetFileName( "image.png" );<br>>
_imageViewer->SetInputConnection( reader->GetOutputPort() );<br>> <br>> it shows me a grayscale pattern that does not really look like the input<br>> image.<br>> <br>> =============================================================<br>> <br>> It would be great if you could give me a hint how to properly use<br>> vtkImageViewer2.<br>> <br>> Thanks,<br>> Jan<br>> <br>> <br>> VTK: 5.0.4<br>> ITK: 3.4.0<br>> QT: 4.3<br>> gcc: 4.2.1 (SUSE Linux)<br>> OpenSuSE 10.3 64bit<br>> <br>> <br>> <br>> _______________________________________________<br>> This is the private VTK discussion list.<br>> Please keep messages on-topic. Check the FAQ at: <br>> <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>> Follow this link to subscribe/unsubscribe:<br>> <a href="http://www.vtk.org/mailman/listinfo/vtkusers"
target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>> <br><br>_______________________________________________<br>This is the private VTK discussion list.<br>Please keep messages on-topic. Check the FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>Follow this link to subscribe/unsubscribe:<br><a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br></div></div></div><br>
</body></html>