<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">Hi David,<br><br>I was tested then now. But the results are empty slices yet. <br>The spacing values are (just to better explain):<br>Before SetOutputSpacing:<br>- 0.9765625<br>- 0.9765625<br>- 3.4000...<br><br>When I set OutputSpacing to minSpacing, the spacing in all axis will be 0.9765625, wich are the minimum spacing in all axis.<br>These two values are to coronal and sagittal axis, and the series are in transversal axis, wich have the 3.4000.... spacing.<br>After the update information, the spacing will return to the original value. <br>Just to make simple, I'll use only coronal axys:<br>- The result for an GetExtent(int[6]) are 0 to 511 to this axy;<br>- Using the value 0.97... ( spacing before SetOutputSpacing and after
 UpdateInformation ), only 255 slices will be valid.<br>- After multiplication ( 0.97... * 0.5 ) all 511 slices are writed. <br>I was used the factor 0.5 just because only&nbsp; half of the 511slices are ok.<br>I'm a little bit confused if the axis spacing value are not ok, or information at my dataset ( I think a good dataset, are from OsiriX ) are wrong, or I'm completely wrong...<br>Just because that I was asked by "how factor I can safely use?".<br>If you have some idea, thks in advance.<br><br><br>Regards,<br>Wagner Sales<br><br><br><br><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;">----- Mensagem original ----<br>De: David Gobbi &lt;dgobbi@atamai.com&gt;<br>Para: Wagner Sales &lt;wsalles2003@yahoo.com.br&gt;<br>Cc: vtkusers@vtk.org<br>Enviadas: Sábado, 21 de Abril de 2007 13:10:06<br>Assunto: Re: [vtkusers] Extracting Slices using vtkImageReslice - Calculating extract spacing factor<br><br><div>Hi Wagner,<br><br>I think that I
 know what the error in your code is.<br><br>Since you are setting the OutputSpacing() to minSpacing.&nbsp;&nbsp;This means<br>the spacing of the output will always be minSpacing regardless of<br>whether you are looking at the x spacing, y spacing or z spacing.<br><br>Maybe what you should do instead is get the input spacing:<br><br>&nbsp;&nbsp;m_ImageData-&gt;UpdateInformation();<br>&nbsp;&nbsp;m_ImageData-&gt;GetSpacing()[i];<br><br>This will return the original spacing as stored in the DICOM file,<br>which will allow you to properly go through the data set<br>slice-by-slice.<br><br> - David<br><br><br>On 4/21/07, Wagner Sales &lt;wsalles2003@yahoo.com.br&gt; wrote:<br>&gt;<br>&gt; Hi all,<br>&gt;<br>&gt; I'm extracting slices from a DICOM dataset and writing on disk. The aproach<br>&gt; are following:<br>&gt; - Load using vtkDICOMImageReader;<br>&gt; - Extract slices using vtkImageReslice.<br>&gt; - Write using vtkPNGImageWriter<br>&gt;<br>&gt; --
 CODE:<br>&gt;&nbsp;&nbsp;m_Reslicer-&gt;SetInput(m_ImageData);<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_Reslicer-&gt;SetInterpolationModeToLinear();<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;double minSpacing = fabs(spacing[0]);<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (fabs(spacing[1]) &lt; minSpacing)<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;minSpacing = fabs(spacing[1]);<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (fabs(spacing[2]) &lt; minSpacing)<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;minSpacing = fabs(spacing[2]);<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_Reslicer-&gt;SetOutputSpacing(minSpacing, minSpacing,<br>&gt;
 minSpacing);<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_Reslicer-&gt;GetOutput()-&gt;UpdateInformation();<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_Reslicer-&gt;SetOutputDimensionality(2);<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_Reslicer-&gt;SetResliceAxes(m_Matrix);<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_Reslicer-&gt;GetOutput()-&gt;UpdateInformation();<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;double point[4];<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;double temp[4];<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;point[0] = 0.0;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;point[1] = 0.0;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;switch(m_Axy)<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case VolumeRepresentation::Coronal:<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;point[2] =<br>&gt; m_Reslicer-&gt;GetOutput()-&gt;GetSpacing()[0] *
 0.5 // what's<br>&gt; are the factor?;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case VolumeRepresentation::Saggital:<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;point[2] =<br>&gt; m_Reslicer-&gt;GetOutput()-&gt;GetSpacing()[1] * 0.5 // what's<br>&gt; are the factor?;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case VolumeRepresentation::Transversal:<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;point[2] =<br>&gt;
 m_Reslicer-&gt;GetOutput()-&gt;GetSpacing()[2];<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vtkMatrix4x4 *matrix = m_Reslicer-&gt;GetResliceAxes();<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;point[3] = 1.0;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;matrix-&gt;MultiplyPoint(point, temp);<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;matrix-&gt;SetElement(0, 3, temp[0]);<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;matrix-&gt;SetElement(1, 3, temp[1]);<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;matrix-&gt;SetElement(2, 3, temp[2]);<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_Reslicer-&gt;Update();<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m_Slice-&gt;DeepCopy(m_Reslicer-&gt;GetOutput());<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return
 m_Slice;<br>&gt;<br>&gt;<br>&gt; When I extract slices from the transversal axis, all are extracted ok, but<br>&gt; when I extract from coronal and sagittal axis, a lot of slices are empty.<br>&gt; After some playing, I was discovered that's my error are these lines:<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; point[2] = m_Reslicer-&gt;GetOutput()-&gt;GetSpacing()[];<br>&gt;<br>&gt; Then I was multiplied, when extracting coronal or sagittal slices, like<br>&gt; showed in the code.<br>&gt; Works fine! No empty slices anymore! But, the factor are fixed, and I don't<br>&gt; know how to calculate the factor 0.5.<br>&gt; I'm completely wrong? Someone can help?<br>&gt;<br>&gt; Thks in advance,<br>&gt;<br>&gt; Wagner Sales<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt;<br>&gt; __________________________________________________<br>&gt; Fale com seus amigos de graça com o novo Yahoo! Messenger<br>&gt; <a target="_blank"
 href="http://br.messenger.yahoo.com/">http://br.messenger.yahoo.com/</a><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 target="_blank" href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a><br>&gt; Follow this link to subscribe/unsubscribe:<br>&gt; <a target="_blank" href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>&gt;<br>&gt;<br>_______________________________________________<br>This is the private VTK discussion list.<br>Please keep messages on-topic. Check the FAQ at: <a target="_blank" href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a><br>Follow this link to subscribe/unsubscribe:<br><a target="_blank"
 href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br></div></div><br></div></div><br>__________________________________________________<br>Fale com seus amigos  de graça com o novo Yahoo! Messenger <br>http://br.messenger.yahoo.com/ </body></html>