<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>&nbsp;&nbsp;&nbsp; vtkImageShiftScale *shiftscalefilter = vtkImageShiftScale::New();<br>&nbsp;&nbsp;&nbsp; shiftscalefilter-&gt;SetInput(itk2vtk-&gt;GetOutput());<br>&nbsp;&nbsp;&nbsp; shiftscalefilter-&gt;SetOutputScalarTypeToUnsignedChar ();<br>&nbsp;&nbsp;&nbsp; _imageViewer-&gt;SetInputConnection(shiftscalefilter-&gt;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 &lt;vtk@schreiber2.de&gt;<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>&nbsp; &nbsp;  typedef itk::Image&lt; unsigned char, 2 &gt; ImageType;<br>&nbsp; &nbsp;  typedef itk::ImageFileReader&lt; ImageType &gt; 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>&gt; <br>&gt; <br>&gt; Hi Jan,<br>&gt; <br>&gt; Have you tried the ITK+VTK connection reading just one image file for <br>&gt; now? see if you can make that work before you try reading several <br>&gt; slices. If you read in the image as &lt;unsigned char, 2&gt; the you shouldn't <br>&gt; get the second error message anymore.<br>&gt; <br>&gt; - John<br>&gt; <br>&gt; <br>&gt;
 -----Original Message-----<br>&gt; From: <a ymailto="mailto:vtkusers-bounces@vtk.org" href="mailto:vtkusers-bounces@vtk.org">vtkusers-bounces@vtk.org</a> on behalf of Jan<br>&gt; Sent: Wed 6/18/2008 6:22 PM<br>&gt; To: <a ymailto="mailto:vtkusers@vtk.org" href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a><br>&gt; Subject: [vtkusers] Error messages and no image with vtkImageViewer2<br>&gt; <br>&gt; Hi,<br>&gt; <br>&gt; I am writing a little QT application using ITK and VTK, trying to use<br>&gt; vtkIMageViewer2.<br>&gt; <br>&gt; During startup, I get the following error messages:<br>&gt; <br>&gt; ERROR: In VTK-504/Filtering/vtkDemandDrivenPipeline.cxx, line 710<br>&gt; vtkStreamingDemandDrivenPipeline (0x11b8570): Input port 0 of algorithm<br>&gt; vtkImageMapToWindowLevelColors(0x118dc50) has 0 connections but is not<br>&gt; optional.<br>&gt; <br>&gt; ERROR: In VTK-504/Rendering/vtkImageActor.cxx, line 182<br>&gt; vtkOpenGLImageActor (0x11bfaf0): This
 filter requires unsigned char<br>&gt; scalars as input<br>&gt; <br>&gt; And the view keeps blank<br>&gt; <br>&gt; <br>&gt; =============================================================<br>&gt; Code:<br>&gt; =============================================================<br>&gt; ViewingWidget.h:<br>&gt; ...<br>&gt; QVTKWidget _view;<br>&gt; ...<br>&gt; <br>&gt; ViewingWidget.cpp:<br>&gt; ...<br>&gt; ViewingWidget::ViewingWidget( const char* name) :<br>&gt;&nbsp; &nbsp; &nbsp; QWidget()<br>&gt; {<br>&gt;&nbsp; &nbsp; &nbsp; _imageViewer = vtkImageViewer2::New();<br>&gt;&nbsp; &nbsp; &nbsp; _view.setParent( this );<br>&gt;&nbsp; &nbsp; &nbsp; _view.SetRenderWindow( _imageViewer-&gt;GetRenderWindow() );<br>&gt;&nbsp; &nbsp; &nbsp; _imageViewer-&gt;SetupInteractor(<br>&gt; _view.GetRenderWindow()-&gt;GetInteractor() );<br>&gt;&nbsp; &nbsp; &nbsp; _imageViewer-&gt;SetColorLevel( 100 );<br>&gt;&nbsp; &nbsp; &nbsp; _imageViewer-&gt;SetColorWindow( 256 );<br>&gt;
 }<br>&gt; ...<br>&gt; <br>&gt; loading the image comes later when pressing a button.<br>&gt; <br>&gt; typedef itk::Image&lt; unsigned char, 3 &gt; ImageType;<br>&gt; typedef itk::ImageSeriesReader&lt; ImageType &gt; ReaderType;<br>&gt; typedef itk::ImageToVTKImageFilter&lt; ImageType &gt; FilterType;<br>&gt; <br>&gt; ImageType::Pointer image;<br>&gt; ReaderType::Pointer reader = ReaderType::New();<br>&gt; FilterType::Pointer itk2vtk;<br>&gt; ...<br>&gt; reader-&gt;SetFileNames( names );<br>&gt; reader-&gt;Update();<br>&gt; image = reader-&gt;GetOutput();<br>&gt; <br>&gt; itk2vtk-&gt;SetInput( image );<br>&gt; _imageViewer-&gt;SetInput( itk2vtk-&gt;GetOutput() );<br>&gt; =============================================================<br>&gt; <br>&gt; when I use<br>&gt; <br>&gt;&nbsp; &nbsp; &nbsp; vtkPNGReader* reader = vtkPNGReader::New();<br>&gt;&nbsp; &nbsp; &nbsp; reader-&gt;SetFileName( "image.png" );<br>&gt;&nbsp; &nbsp; &nbsp;
 _imageViewer-&gt;SetInputConnection( reader-&gt;GetOutputPort() );<br>&gt; <br>&gt; it shows me a grayscale pattern that does not really look like the input<br>&gt; image.<br>&gt; <br>&gt; =============================================================<br>&gt; <br>&gt; It would be great if you could give me a hint how to properly use<br>&gt; vtkImageViewer2.<br>&gt; <br>&gt; Thanks,<br>&gt; Jan<br>&gt; <br>&gt; <br>&gt; VTK: 5.0.4<br>&gt; ITK: 3.4.0<br>&gt; QT:&nbsp; 4.3<br>&gt; gcc: 4.2.1 (SUSE Linux)<br>&gt; OpenSuSE 10.3 64bit<br>&gt; <br>&gt; <br>&gt; <br>&gt; _______________________________________________<br>&gt; This is the private VTK discussion list.<br>&gt; Please keep messages on-topic. Check the FAQ at: <br>&gt; <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>&gt; Follow this link to subscribe/unsubscribe:<br>&gt; <a href="http://www.vtk.org/mailman/listinfo/vtkusers"
 target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>&gt; <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>