<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 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 <dgobbi@atamai.com><br>Para: Wagner Sales <wsalles2003@yahoo.com.br><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. 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> m_ImageData->UpdateInformation();<br> m_ImageData->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 <wsalles2003@yahoo.com.br> wrote:<br>><br>> Hi all,<br>><br>> I'm extracting slices from a DICOM dataset and writing on disk. The aproach<br>> are following:<br>> - Load using vtkDICOMImageReader;<br>> - Extract slices using vtkImageReslice.<br>> - Write using vtkPNGImageWriter<br>><br>> --
CODE:<br>> m_Reslicer->SetInput(m_ImageData);<br>> m_Reslicer->SetInterpolationModeToLinear();<br>> double minSpacing = fabs(spacing[0]);<br>> if (fabs(spacing[1]) < minSpacing)<br>> {<br>> minSpacing = fabs(spacing[1]);<br>> }<br>> if (fabs(spacing[2]) < minSpacing)<br>> {<br>> minSpacing = fabs(spacing[2]);<br>> }<br>> m_Reslicer->SetOutputSpacing(minSpacing, minSpacing,<br>>
minSpacing);<br>> m_Reslicer->GetOutput()->UpdateInformation();<br>> m_Reslicer->SetOutputDimensionality(2);<br>> m_Reslicer->SetResliceAxes(m_Matrix);<br>> m_Reslicer->GetOutput()->UpdateInformation();<br>> double point[4];<br>> double temp[4];<br>> point[0] = 0.0;<br>> point[1] = 0.0;<br>> switch(m_Axy)<br>> {<br>> case VolumeRepresentation::Coronal:<br>> point[2] =<br>> m_Reslicer->GetOutput()->GetSpacing()[0] *
0.5 // what's<br>> are the factor?;<br>> break;<br>> case VolumeRepresentation::Saggital:<br>> point[2] =<br>> m_Reslicer->GetOutput()->GetSpacing()[1] * 0.5 // what's<br>> are the factor?;<br>> break;<br>> case VolumeRepresentation::Transversal:<br>> point[2] =<br>>
m_Reslicer->GetOutput()->GetSpacing()[2];<br>> break;<br>> }<br>> vtkMatrix4x4 *matrix = m_Reslicer->GetResliceAxes();<br>> point[3] = 1.0;<br>> matrix->MultiplyPoint(point, temp);<br>> matrix->SetElement(0, 3, temp[0]);<br>> matrix->SetElement(1, 3, temp[1]);<br>> matrix->SetElement(2, 3, temp[2]);<br>> m_Reslicer->Update();<br>> m_Slice->DeepCopy(m_Reslicer->GetOutput());<br>> return
m_Slice;<br>><br>><br>> When I extract slices from the transversal axis, all are extracted ok, but<br>> when I extract from coronal and sagittal axis, a lot of slices are empty.<br>> After some playing, I was discovered that's my error are these lines:<br>><br>> point[2] = m_Reslicer->GetOutput()->GetSpacing()[];<br>><br>> Then I was multiplied, when extracting coronal or sagittal slices, like<br>> showed in the code.<br>> Works fine! No empty slices anymore! But, the factor are fixed, and I don't<br>> know how to calculate the factor 0.5.<br>> I'm completely wrong? Someone can help?<br>><br>> Thks in advance,<br>><br>> Wagner Sales<br>><br>><br>><br>><br>><br>> __________________________________________________<br>> Fale com seus amigos de graça com o novo Yahoo! Messenger<br>> <a target="_blank"
href="http://br.messenger.yahoo.com/">http://br.messenger.yahoo.com/</a><br>> _______________________________________________<br>> This is the private VTK discussion list.<br>> Please keep messages on-topic. Check the FAQ at:<br>> <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>><br>><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>