<font size="2"><font face="verdana,sans-serif">Hi David,<br></font></font><div><font class="Apple-style-span" face="verdana, sans-serif"><br></font></div><div><font class="Apple-style-span" face="verdana, sans-serif">with this I try to do what you suggested, i.e. consider VTK's world coordinate system as </font><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">DICOM patient coordinate system:</span></div>
<div><font class="Apple-style-span" face="verdana, sans-serif"><br></font></div><div><div><font class="Apple-style-span" face="'courier new', monospace"><div>//red is the transformation-related code</div><div>void MainWindow::updateVisualization()</div>
<div>{</div><div> typedef itk::ImageToVTKImageFilter<VisualizingImageType> itkVtkConverter;</div><div> itkVtkConverter::Pointer conv=itkVtkConverter::New();</div><div> conv->SetInput(logic->visualizing);</div>
<div><br></div><div> vtkGPUVolumeRayCastMapper *mapper = vtkGPUVolumeRayCastMapper::New();</div><div> mapper->SetInput(conv->GetOutput());</div><div><br></div><div> if (volume)</div><div> volume->Delete();</div>
<div> volume=vtkVolume::New();</div><div> volume->SetProperty( myTransferFunction );</div><div> volume->SetMapper( mapper );</div><div> mapper->SetBlendModeToComposite();</div><div><br></div><div><font class="Apple-style-span" color="#ff0000"> VisualizingImageType::DirectionType d=logic->visualizing->GetDirection();</font></div>
<div><font class="Apple-style-span" color="#ff0000"> vtkMatrix4x4 *mat=vtkMatrix4x4::New();</font></div><div><font class="Apple-style-span" color="#ff0000"> for (int i=0; i<3; i++)</font></div><div><font class="Apple-style-span" color="#ff0000"> for (int k=0; k<3; k++)</font></div>
<div><font class="Apple-style-span" color="#ff0000"> mat->SetElement(i,k, d(i,k));</font></div><div><font class="Apple-style-span" color="#ff0000"> mat->SetElement(3,3, 1);</font></div><div><font class="Apple-style-span" color="#ff0000"> VisualizingImageType::SpacingType sp = logic->visualizing->GetSpacing();</font></div>
<div><font class="Apple-style-span" color="#ff0000"> VisualizingImageType::PointType origin=logic->visualizing->GetOrigin();</font></div><div><font class="Apple-style-span" color="#ff0000"> for (int i=0; i<3; i++)</font></div>
<div><font class="Apple-style-span" color="#ff0000"> mat->SetElement(i,3, origin[i]/sp[i]);</font></div><div><font class="Apple-style-span" color="#ff0000"> volume->SetUserMatrix(mat); //orientation and size OK, position wrong</font></div>
<div><br></div><div> vtkRenderer *renderer = vis->GetRenderWindow()->GetRenderers()->GetFirstRenderer();</div><div> renderer->RemoveAllViewProps();</div><div> renderer->AddVolume( volume ); </div>
<div> defaultCameraPos(); //centers view on the volume, looking at it from left </div><div> vis->GetRenderWindow()->Render();</div><div> vis->GetRenderWindow()->GetRenderers()->GetFirstRenderer()->ResetCamera();</div>
<div>}</div></font></div></div><div><font class="Apple-style-span" face="verdana, sans-serif"><br></font></div><div><font class="Apple-style-span" face="verdana, sans-serif">The polygonal data is in </font><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; ">DICOM's patient coordinate system (vertex positions from itk::Image->TransformIndexToPhysicalPoint() etc). The orientation is correct, but</span><span class="Apple-style-span" style="font-family: verdana, sans-serif; "> I can't get the position correctly. I have tried -origin[i]/sp[i], </span><span class="Apple-style-span" style="font-family: verdana, sans-serif; ">origin[i]*sp[i], origin[i], -origin[i], -2*origin[i] and similar combinations but none of them worked. Any suggestion to what am I doing wrong?</span></div>
<div><font class="Apple-style-span" face="verdana, sans-serif"><br></font></div><div><font class="Apple-style-span" face="verdana, sans-serif">Regards,</font></div><div><font class="Apple-style-span" face="verdana, sans-serif">Dženan</font></div>
<div><font class="Apple-style-span" face="verdana, sans-serif"><br></font><div class="gmail_quote">2011/6/29 David Gobbi <span dir="ltr"><<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Tue, Jun 28, 2011 at 9:40 AM, Dženan Zukić <<a href="mailto:dzenanz@gmail.com">dzenanz@gmail.com</a>> wrote:<br>
> Hi David,<br>
><br>
> I am interested in this too:<br>
</div><div class="im">> Does the above approach affect the polygonal actors in the scene (segmented<br>
> parts of the image)?<br>
> Regards,<br>
> Dženan<br>
<br>
</div>When the DICOM patient coordinate system is used as the VTK world<br>
coordinate system, the assumption is that everything (images AND<br>
polydata) would have a either already be in the patient coordinate<br>
system, or if not, you would to have a 4x4 transform to set as the<br>
actor's UserMatrix (or UserTransform). I.e. a transform to bring the<br>
data from its original coordinate system into the patient coordinate<br>
system.<br>
<font color="#888888"><br>
- David<br>
</font></blockquote></div><br></div>