<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    <br>
    Hello,<br>
    <br>
    I'm new to VTK and I'm working on a project that reads dicom image
    files.&nbsp; The files I have are 512x512 pixels, but when I view them
    they display at approx 150x150 pixels.&nbsp; I'm using Qt to create the
    UI via Qt designer with the qvtkWidget.&nbsp; I'm using the
    vtkImageViewer2 class to handle the visualization.&nbsp; I pasted my
    initialization code below.&nbsp; The algorithm I'm working on is
    intelligent scissors (user guided segmentation).&nbsp; I originally
    implemented it in OpenCV, but need to convert my app. to use VTK.&nbsp; I
    need to extract pixel locations from left click and mouse over
    events, and I have this part working correctly.&nbsp; However, for the
    algorithm to work properly I need to do a lookup into a cost table
    based on pixel location.&nbsp; The cost table is built to the correct
    size (512x512), and when I write out the dimensions of the image I
    see 512x512, but when I do the picking I get locations in the range
    of 0 - 150.&nbsp; Indeed, the displayed image takes up only a small
    portion of the widget (see image below).&nbsp; I tried searching the web
    and the mailing list, but found nothing.&nbsp; I'm not sure what search
    terms are appropriate.&nbsp; I found in the vtkImageViewer2 documentation
    that dicom images are scaled by Z coordinate of the image slice.&nbsp;
    When I print out the position of the image the z coord is 0, but I
    don't know what (or how to get) the position of the camera is.&nbsp; How
    can I make the visualization pipeline display the image at full
    size?<br>
    <br>
    Thank you in advance for any help or suggestions.<br>
    <br>
    Regards,<br>
    <br>
    Joseph.<br>
    <br>
    <tt>MainWindow::MainWindow( QWidget *parent, const string&amp; fname
      ) :<br>
      &nbsp;&nbsp;&nbsp; QMainWindow( parent ),<br>
      &nbsp;&nbsp;&nbsp; ui( new Ui::MainWindow ),<br>
      &nbsp;&nbsp;&nbsp; m_fileName( fname )<br>
      {<br>
      &nbsp;&nbsp;&nbsp; ui-&gt;setupUi( this );<br>
      <br>
      &nbsp;&nbsp;&nbsp; // Read the image<br>
      &nbsp;&nbsp;&nbsp; vtkSmartPointer&lt; vtkDICOMImageReader &gt; reader =<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkSmartPointer&lt; vtkDICOMImageReader &gt;::New();<br>
      &nbsp;&nbsp;&nbsp; reader-&gt;SetFileName( m_fileName.c_str () );<br>
      &nbsp;&nbsp;&nbsp; reader-&gt;Update ();<br>
      <br>
      &nbsp;&nbsp;&nbsp; // setup the intelligent scissors object<br>
      &nbsp;&nbsp;&nbsp; //mexican hat LoG<br>
      &nbsp;&nbsp;&nbsp; double laplacian[] = {&nbsp; 0.,&nbsp; 0., -1.,&nbsp; 0.,&nbsp; 0.,<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0., -1., -2., -1.,&nbsp; 0.,<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -1., -2., 16., -2., -1.,<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0., -1., -2., -1.,&nbsp; 0.,<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.,&nbsp; 0., -1.,&nbsp; 0.,&nbsp; 0. };<br>
      <br>
      &nbsp;&nbsp;&nbsp; m_spScissors.reset( new IntelligentScissors(
      reader-&gt;GetOutput (),<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; laplacian ) );<br>
      <br>
      &nbsp;&nbsp;&nbsp; // Setup the blending function to overlay the segmentation
      contour on the image<br>
      &nbsp;&nbsp;&nbsp; vtkSmartPointer&lt; vtkImageBlend &gt; blend =<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkSmartPointer&lt; vtkImageBlend &gt;::New();<br>
      &nbsp;&nbsp;&nbsp; blend-&gt;AddInputConnection( reader-&gt;GetOutputPort() );<br>
      &nbsp;&nbsp;&nbsp; blend-&gt;SetOpacity( 0, 0.6 );<br>
      &nbsp;&nbsp;&nbsp; blend-&gt;AddInputConnection( m_spScissors-&gt;getPathImage ()
      );<br>
      &nbsp;&nbsp;&nbsp; blend-&gt;SetOpacity( 1, 0.4 );<br>
      <br>
      &nbsp;&nbsp;&nbsp; vtkSmartPointer&lt; vtkImageViewer2 &gt; viewer =<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkSmartPointer&lt; vtkImageViewer2 &gt;::New();<br>
      &nbsp;&nbsp;&nbsp; viewer-&gt;SetInputConnection ( blend-&gt;GetOutputPort () );<br>
      <br>
      &nbsp;&nbsp;&nbsp; // make the viewer use the interactor supplied from the qvtk
      widget<br>
      &nbsp;&nbsp;&nbsp; viewer-&gt;SetupInteractor (
      ui-&gt;qvtkWidget-&gt;GetInteractor () );<br>
      <br>
      &nbsp;&nbsp;&nbsp; //bind Qt and VTK<br>
      &nbsp;&nbsp;&nbsp; ui-&gt;qvtkWidget-&gt;SetRenderWindow (
      viewer-&gt;GetRenderWindow () );<br>
      <br>
      &nbsp;&nbsp;&nbsp; //try to get image displayed at full size<br>
      &nbsp;&nbsp;&nbsp; viewer-&gt;GetInteractorStyle
      ()-&gt;AutoAdjustCameraClippingRangeOff ();<br>
      <br>
      &nbsp;&nbsp;&nbsp; // Annotate the image with mouse over pixel information<br>
      &nbsp;&nbsp;&nbsp; vtkSmartPointer&lt; vtkCornerAnnotation &gt; cornerAnnotation
      =<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkSmartPointer&lt; vtkCornerAnnotation &gt;::New();<br>
      &nbsp;&nbsp;&nbsp; cornerAnnotation-&gt;SetLinearFontScaleFactor( 2 );<br>
      &nbsp;&nbsp;&nbsp; cornerAnnotation-&gt;SetNonlinearFontScaleFactor( 1 );<br>
      &nbsp;&nbsp;&nbsp; cornerAnnotation-&gt;SetMaximumFontSize( 15 );<br>
      &nbsp;&nbsp;&nbsp; cornerAnnotation-&gt;SetText( 0, "Off Image" );<br>
      &nbsp;&nbsp;&nbsp; cornerAnnotation-&gt;SetText( 3,
      "&lt;window&gt;\n&lt;level&gt;" );<br>
      &nbsp;&nbsp;&nbsp; cornerAnnotation-&gt;GetTextProperty()-&gt;SetColor( 1, 0, 0
      );<br>
      &nbsp;&nbsp;&nbsp; viewer-&gt;GetRenderer ()-&gt;AddViewProp ( cornerAnnotation
      );<br>
      <br>
      &nbsp;&nbsp;&nbsp; // Picker to pick pixels<br>
      &nbsp;&nbsp;&nbsp; vtkSmartPointer&lt; vtkPropPicker &gt; propPicker =<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkSmartPointer&lt; vtkPropPicker &gt;::New();<br>
      &nbsp;&nbsp;&nbsp; propPicker-&gt;PickFromListOn();<br>
      <br>
      &nbsp;&nbsp;&nbsp; // Give the picker a prop to pick<br>
      &nbsp;&nbsp;&nbsp; vtkImageActor* imageActor = viewer-&gt;GetImageActor();<br>
      &nbsp;&nbsp;&nbsp; propPicker-&gt;AddPickList( imageActor );<br>
      <br>
      &nbsp;&nbsp;&nbsp; // disable interpolation, so we can see each pixel<br>
      &nbsp;&nbsp;&nbsp; imageActor-&gt;InterpolateOff();<br>
      <br>
      &nbsp;&nbsp;&nbsp; // Set callback functions<br>
      &nbsp;&nbsp;&nbsp; vtkInteractorStyleImage* imageStyle =
      viewer-&gt;GetInteractorStyle();<br>
      <br>
      &nbsp;&nbsp;&nbsp; //listen to MouseMoveEvents invoked by the interactor's style<br>
      &nbsp;&nbsp;&nbsp; OnMouseMovePtr onMouseMove = OnMouseMovePtr::New();<br>
      &nbsp;&nbsp;&nbsp; onMouseMove-&gt;SetViewer( viewer );<br>
      &nbsp;&nbsp;&nbsp; onMouseMove-&gt;SetAnnotation( cornerAnnotation );<br>
      &nbsp;&nbsp;&nbsp; onMouseMove-&gt;SetPicker( propPicker );<br>
      &nbsp;&nbsp;&nbsp; onMouseMove-&gt;SetIntelligentScissors ( m_spScissors );<br>
      &nbsp;&nbsp;&nbsp; imageStyle-&gt;AddObserver( vtkCommand::MouseMoveEvent,
      onMouseMove );<br>
      <br>
      &nbsp;&nbsp;&nbsp; //listen to LeftButtonPressEvent invoked by the interactor's
      style<br>
      &nbsp;&nbsp;&nbsp; OnLeftClickPtr onLeftClick = OnLeftClickPtr::New ();<br>
      &nbsp;&nbsp;&nbsp; onLeftClick-&gt;SetViewer ( viewer );<br>
      &nbsp;&nbsp;&nbsp; onLeftClick-&gt;SetAnnotation ( cornerAnnotation );<br>
      &nbsp;&nbsp;&nbsp; onLeftClick-&gt;SetPicker ( propPicker );<br>
      &nbsp;&nbsp;&nbsp; onLeftClick-&gt;SetIntelligentScissors ( m_spScissors );<br>
      &nbsp;&nbsp;&nbsp; imageStyle-&gt;AddObserver ( vtkCommand::LeftButtonPressEvent,
      onLeftClick );<br>
      <br>
      &nbsp;&nbsp;&nbsp; viewer-&gt;Render ();<br>
      }</tt><br>
    <br>
    <br>
    <img alt="View in HTML to see image"
      src="cid:part1.05010608.09090209@gmail.com" height="707"
      width="684"><br>
  </body>
</html>