<div dir="ltr">Thank you bu I just did that and I still get GetWholeZMax() returning 0...<br><br><div class="gmail_quote">2008/9/24 David Gobbi <span dir="ltr"><<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Talita,<br>
<br>
When reslice->SetOutputDimensionality(2) is used, the output of<br>
vtkImageReslice contains only one slice. That is why GetWholeZMax()<br>
is returning zero.<br>
<br>
To just change the axes without doing anything else to the image, use<br>
SetOutputDimensionality(3) and do not set the "center" in the<br>
resliceAxes.<br>
<br>
David<br>
<div><div></div><div class="Wj3C7c"><br>
<br>
<br>
On Tue, Sep 23, 2008 at 10:16 PM, Talita Perciano<br>
<<a href="mailto:talitaperciano@gmail.com">talitaperciano@gmail.com</a>> wrote:<br>
> Hello,<br>
><br>
> I'm trying to read DICOM image slices and to view them with a<br>
> vtkImageViewer. The thing is that I want to change the axis before I view<br>
> the slices, that is, if the slices are in axial direction I want to change<br>
> it to coronal direction. I'm doing that using the a vtkImageReslice. The<br>
> thing is that when I pass the DICOM reader directly to the vtkImageViewer<br>
> things work fine. However, when I use first the vtkImageReslice and than<br>
> pass it to the vtkImageViewer I can't view the slices anymore. It's strange<br>
> because when I call GetWholeZMax it returns 0. Does anybody could help me?<br>
> The code is attached.<br>
><br>
> Thank you,<br>
><br>
> Talita<br>
><br>
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<br>
><br>
> std::string strFolderPath = "/home/talita/Desktop/COMUNIX/Neck<br>
> 1HEAD_NECK_PETCT/CT HEAD-NK 5.0 B30s";<br>
><br>
> vtkDICOMImageReader *reader = vtkDICOMImageReader::New();<br>
> reader->SetDirectoryName (strFolderPath.c_str());<br>
> reader->Update();<br>
><br>
> reader->SetDataScalarTypeToUnsignedShort();<br>
> reader->UpdateWholeExtent();<br>
><br>
> // Calculate the center of the volume<br>
> reader->GetOutput()->UpdateInformation();<br>
> int extent[6];<br>
> double spacing[3];<br>
> double origin[3];<br>
> reader->GetOutput()->GetWholeExtent(extent);<br>
> reader->GetOutput()->GetSpacing(spacing);<br>
> reader->GetOutput()->GetOrigin(origin);<br>
><br>
> double center[3];<br>
> center[0] = origin[0] + spacing[0] * 0.5 * (extent[0] + extent[1]);<br>
> center[1] = origin[1] + spacing[1] * 0.5 * (extent[2] + extent[3]);<br>
> center[2] = origin[2] + spacing[2] * 0.5 * (extent[4] + extent[5]);<br>
><br>
> // Matrices for axial, coronal, sagittal, oblique view orientations<br>
> static double axialElements[16] = {<br>
> 1, 0, 0, 0,<br>
> 0, 1, 0, 0,<br>
> 0, 0, 1, 0,<br>
> 0, 0, 0, 1 };<br>
><br>
> static double coronalElements[16] = {<br>
> 1, 0, 0, 0,<br>
> 0, 0, 1, 0,<br>
> 0,-1, 0, 0,<br>
> 0, 0, 0, 1 };<br>
><br>
> static double sagittalElements[16] = {<br>
> 0, 0,-1, 0,<br>
> 1, 0, 0, 0,<br>
> 0,-1, 0, 0,<br>
> 0, 0, 0, 1 };<br>
><br>
> //static double obliqueElements[16] = {<br>
> // 1, 0, 0, 0,<br>
> // 0, 0.866025, -0.5, 0,<br>
> // 0, 0.5, 0.866025, 0,<br>
> // 0, 0, 0, 1 };<br>
><br>
> // Set the slice orientation<br>
> vtkMatrix4x4 *resliceAxes = vtkMatrix4x4::New();<br>
> resliceAxes->DeepCopy(coronalElements);<br>
> // Set the point through which to slice<br>
> resliceAxes->SetElement(0, 3, center[0]);<br>
> resliceAxes->SetElement(1, 3, center[1]);<br>
> resliceAxes->SetElement(2, 3, center[2]);<br>
><br>
> // Extract a slice in the desired orientation<br>
> vtkImageReslice *reslice = vtkImageReslice::New();<br>
> reslice->SetInputConnection(reader->GetOutputPort());<br>
> reslice->SetOutputDimensionality(2);<br>
> reslice->SetResliceAxes(resliceAxes);<br>
> //reslice->SetInterpolationModeToNearestNeighbor();<br>
><br>
> // Create a greyscale lookup table<br>
> vtkLookupTable *table = vtkLookupTable::New();<br>
> table->SetRange(0, 2000); // image intensity range<br>
> table->SetValueRange(0.0, 1.0); // from black to white<br>
> table->SetSaturationRange(0.0, 0.0); // no color saturation<br>
> table->SetRampToLinear();<br>
> table->Build();<br>
><br>
> // Map the image through the lookup table<br>
> vtkImageMapToColors *color = vtkImageMapToColors::New();<br>
> color->SetLookupTable(table);<br>
> color->SetInputConnection(reslice->GetOutputPort());<br>
><br>
> vtkImageViewer *viewer = vtkImageViewer::New();<br>
><br>
> viewer->SetInput(color->GetOutput());<br>
> printf("\n%d\n",viewer->GetWholeZMax());<br>
> viewer->SetZSlice(35);<br>
> viewer->SetColorWindow(2000);<br>
> viewer->SetColorLevel(1000);<br>
> viewer->Render();<br>
><br>
><br>
</div></div>> _______________________________________________<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>
</blockquote></div><br><br clear="all"><br>-- <br>Talita Perciano<br>Instituto de Matemática e Estatísitca<br>Universidade de São Paulo - USP<br>Doutoranda em Ciência da Computação<br>São Paulo, SP, Brasil<br>Tel: +55 11 8826 7092<br>
<br>"Success is not final, failure is not fatal: it is the courage to continue that counts." <br>(Winston Churchill)<br>
</div>