<!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. The files I have are 512x512 pixels, but when I view them
they display at approx 150x150 pixels. I'm using Qt to create the
UI via Qt designer with the qvtkWidget. I'm using the
vtkImageViewer2 class to handle the visualization. I pasted my
initialization code below. The algorithm I'm working on is
intelligent scissors (user guided segmentation). I originally
implemented it in OpenCV, but need to convert my app. to use VTK. I
need to extract pixel locations from left click and mouse over
events, and I have this part working correctly. However, for the
algorithm to work properly I need to do a lookup into a cost table
based on pixel location. 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. Indeed, the displayed image takes up only a small
portion of the widget (see image below). I tried searching the web
and the mailing list, but found nothing. I'm not sure what search
terms are appropriate. I found in the vtkImageViewer2 documentation
that dicom images are scaled by Z coordinate of the image slice.
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. 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& fname
) :<br>
QMainWindow( parent ),<br>
ui( new Ui::MainWindow ),<br>
m_fileName( fname )<br>
{<br>
ui->setupUi( this );<br>
<br>
// Read the image<br>
vtkSmartPointer< vtkDICOMImageReader > reader =<br>
vtkSmartPointer< vtkDICOMImageReader >::New();<br>
reader->SetFileName( m_fileName.c_str () );<br>
reader->Update ();<br>
<br>
// setup the intelligent scissors object<br>
//mexican hat LoG<br>
double laplacian[] = { 0., 0., -1., 0., 0.,<br>
0., -1., -2., -1., 0.,<br>
-1., -2., 16., -2., -1.,<br>
0., -1., -2., -1., 0.,<br>
0., 0., -1., 0., 0. };<br>
<br>
m_spScissors.reset( new IntelligentScissors(
reader->GetOutput (),<br>
laplacian ) );<br>
<br>
// Setup the blending function to overlay the segmentation
contour on the image<br>
vtkSmartPointer< vtkImageBlend > blend =<br>
vtkSmartPointer< vtkImageBlend >::New();<br>
blend->AddInputConnection( reader->GetOutputPort() );<br>
blend->SetOpacity( 0, 0.6 );<br>
blend->AddInputConnection( m_spScissors->getPathImage ()
);<br>
blend->SetOpacity( 1, 0.4 );<br>
<br>
vtkSmartPointer< vtkImageViewer2 > viewer =<br>
vtkSmartPointer< vtkImageViewer2 >::New();<br>
viewer->SetInputConnection ( blend->GetOutputPort () );<br>
<br>
// make the viewer use the interactor supplied from the qvtk
widget<br>
viewer->SetupInteractor (
ui->qvtkWidget->GetInteractor () );<br>
<br>
//bind Qt and VTK<br>
ui->qvtkWidget->SetRenderWindow (
viewer->GetRenderWindow () );<br>
<br>
//try to get image displayed at full size<br>
viewer->GetInteractorStyle
()->AutoAdjustCameraClippingRangeOff ();<br>
<br>
// Annotate the image with mouse over pixel information<br>
vtkSmartPointer< vtkCornerAnnotation > cornerAnnotation
=<br>
vtkSmartPointer< vtkCornerAnnotation >::New();<br>
cornerAnnotation->SetLinearFontScaleFactor( 2 );<br>
cornerAnnotation->SetNonlinearFontScaleFactor( 1 );<br>
cornerAnnotation->SetMaximumFontSize( 15 );<br>
cornerAnnotation->SetText( 0, "Off Image" );<br>
cornerAnnotation->SetText( 3,
"<window>\n<level>" );<br>
cornerAnnotation->GetTextProperty()->SetColor( 1, 0, 0
);<br>
viewer->GetRenderer ()->AddViewProp ( cornerAnnotation
);<br>
<br>
// Picker to pick pixels<br>
vtkSmartPointer< vtkPropPicker > propPicker =<br>
vtkSmartPointer< vtkPropPicker >::New();<br>
propPicker->PickFromListOn();<br>
<br>
// Give the picker a prop to pick<br>
vtkImageActor* imageActor = viewer->GetImageActor();<br>
propPicker->AddPickList( imageActor );<br>
<br>
// disable interpolation, so we can see each pixel<br>
imageActor->InterpolateOff();<br>
<br>
// Set callback functions<br>
vtkInteractorStyleImage* imageStyle =
viewer->GetInteractorStyle();<br>
<br>
//listen to MouseMoveEvents invoked by the interactor's style<br>
OnMouseMovePtr onMouseMove = OnMouseMovePtr::New();<br>
onMouseMove->SetViewer( viewer );<br>
onMouseMove->SetAnnotation( cornerAnnotation );<br>
onMouseMove->SetPicker( propPicker );<br>
onMouseMove->SetIntelligentScissors ( m_spScissors );<br>
imageStyle->AddObserver( vtkCommand::MouseMoveEvent,
onMouseMove );<br>
<br>
//listen to LeftButtonPressEvent invoked by the interactor's
style<br>
OnLeftClickPtr onLeftClick = OnLeftClickPtr::New ();<br>
onLeftClick->SetViewer ( viewer );<br>
onLeftClick->SetAnnotation ( cornerAnnotation );<br>
onLeftClick->SetPicker ( propPicker );<br>
onLeftClick->SetIntelligentScissors ( m_spScissors );<br>
imageStyle->AddObserver ( vtkCommand::LeftButtonPressEvent,
onLeftClick );<br>
<br>
viewer->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>