<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>Thks, really a stupid mistake from me. <br>Now I'm just setting using the image origin ( in my dataset are 0,0,0 ) to extract the slices.<br>Spacing an extraction works very fine... Except by saggital orientation! In this case, no one slice are extracted.<br>To start, I'm using the following matrices:<br><br>------------------------------------------------------------<br>double SlicerExtractor::transversalElements[16] = { <br> 1, 0, 0, 0,<br> 0, 1, 0, 0,<br> 0, 0, 1, 0,<br> 0, 0, 0,
1 };<br><br>double SlicerExtractor::coronalElements[16] = {<br> 1, 0, 0, 0,<br> 0, 0, 1, 0,<br> 0,-1, 0, 0,<br> 0, 0, 0, 1 };<br><br>double SlicerExtractor::sagittalElements[16] ={<br> 0, 0,-1, 0,<br> 1, 0, 0, 0,<br> 0,-1, 0, 0,<br> 0, 0, 0, 1 };<br>Then, when I'll choose the orientation:<br>switch(m_Axy)<br> {<br> case VolumeRepresentation::Coronal:<br>
m_Matrix->DeepCopy(coronalElements);<br> break;<br> case VolumeRepresentation::Saggital:<br> m_Matrix->DeepCopy(sagittalElements);<br> break;<br> case VolumeRepresentation::Transversal:<br> m_Matrix->DeepCopy(transversalElements);<br> break;<br> }<br> m_Matrix->SetElement(0, 3, origin[0]);<br> m_Matrix->SetElement(1, 3, origin[1]);<br> m_Matrix->SetElement(2, 3, origin[2]);<br>---------------------------------------------------------<br><br><br>And, finally, extract my
slices:<br>---------------------------------------------------------<br>m_ImageData->UpdateInformation();<br> switch(m_Axy)<br> {<br> case VolumeRepresentation::Coronal:<br> point[2] = m_ImageData->GetSpacing()[0]; <br> break;<br> case VolumeRepresentation::Saggital:<br> point[2] = m_ImageData->GetSpacing()[1];<br> break;<br> case VolumeRepresentation::Transversal:<br> point[2] = m_ImageData->GetSpacing()[2];<br> break;<br> }<br> vtkMatrix4x4
*matrix = m_Reslicer->GetResliceAxes();<br> point[3] = 1.0;<br> m_Matrix->MultiplyPoint(point, temp);<br> m_Matrix->SetElement(0, 3, temp[0]);<br> m_Matrix->SetElement(1, 3, temp[1]);<br> m_Matrix->SetElement(2, 3, temp[2]);<br> m_Reslicer->SetResliceAxes(m_Matrix);<br> m_Reslicer->Update();<br> ----------------------------------------------------------- <br><br>If I use the center the slices at the sagittal axis, works well ( except, of course, by the only center-to-end slices are extracted ).<br>I'm thinking thats my sagittal matrix are wrong. <br>If you or someone can help, thks in advance.<br><br>Regards,<br><br>Wagner Sales<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 17:13:54<br>Assunto: Re: Res: [vtkusers] Extracting Slices using vtkImageReslice - Calculating extract spacing factor<br><br><div>Hi Wagner,<br><br>I think the reason this is happening is that you are extracting the <br>first slice from the centre of the volume, and then by the time you have <br>incremented 255 times you have reached the edge of the volume. The rest <br>of the slices will therefore be outside of the bounds of the image. If <br>you set the slice spacing to half, then you are still only extracting <br>slices from half of the volume, but with half of the original slice spacing.<br><br>In your code, you should always set the last column of the ResliceAxes <br>matrix to the point that lies at the centre of the slice that you want <br>to
extract. Right it looks like you are incrementing that point by one <br>slice-spacing each time, but you are starting at the middle of the <br>volume rather than at the first slice.<br><br>The "factor" should never be set to anything except for 1, unless you <br>want to interpolate new slices between the original slices.<br><br> - David<br><br><br><br>Wagner Sales wrote:<br>> 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 <br>> 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 <br>> in transversal axis, wich have the 3.4000.... spacing.<br>> After the update information, the spacing will return to
the original <br>> 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 <br>> 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 <br>> information at my dataset ( I think a good dataset, are from OsiriX ) <br>> 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>> ----- 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 - <br>> Calculating extract spacing factor<br>><br>> 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 <br>> 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 <br>> ok, but<br>> > when I extract from coronal and sagittal axis, a lot of slices are <br>> 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 <br>> 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: <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>> 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>_______________________________________________<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>