Hmnn your code is not working for me, Im trying to do a volume render and it gives me the following error:<br><br>ERROR: In C:\Users\RODRIGO LOVERA\Documents\PUCP\Tesis\VTK 5.10\VTK\VolumeRendering\vtkVolumeRayCastMapper.cxx, line 326<br>
vtkVolumeRayCastMapper (04ADF0A8): Cannot volume render data of type double, only unsigned char or unsigned short.<br><br>ERROR: In C:\Users\RODRIGO LOVERA\Documents\PUCP\Tesis\VTK 5.10\VTK\VolumeRendering\vtkVolumeRayCastMapper.cxx, line 326<br>
vtkVolumeRayCastMapper (04ADF0A8): Cannot volume render data of type double, only unsigned char or unsigned short.<br><br>I think that is probably for the use of vtkImageData.<br><br>My code goes as follows:<br><br>vtkSmartPointer< vtkDICOMImageReader > reader =<br>
vtkSmartPointer< vtkDICOMImageReader >::New();<br> reader->SetDataByteOrderToLittleEndian();<br> reader->SetDirectoryName("C:\\VTK5.10\\DATA\\DICOM");<br> reader->SetDataSpacing(3.2, 3.2, 1.5);<br>
reader->SetDataOrigin(0.0, 0.0, 0.0);<br> reader->Update();<br><br> vtkSmartPointer< vtkImageCast > readerImageCast =<br> vtkSmartPointer< vtkImageCast >::New();<br> readerImageCast->SetInput((vtkDataObject *)reader->GetOutput());<br>
readerImageCast->SetOutputScalarTypeToUnsignedChar();<br> readerImageCast->ClampOverflowOn();<br><br> m_opacityFunction = vtkPiecewiseFunction::New();<br><br> m_colorTransferFunction = vtkColorTransferFunction::New();<br>
<br> vtkSmartPointer< vtkVolumeProperty > volumeProperty =<br> vtkSmartPointer <vtkVolumeProperty >::New();<br> volumeProperty->SetColor(m_colorTransferFunction);<br> volumeProperty->SetScalarOpacity(m_opacityFunction);<br>
volumeProperty->ShadeOn();<br> volumeProperty->SetInterpolationTypeToLinear();<br><br> vtkSmartPointer< vtkVolumeRayCastCompositeFunction > compositeFunction =<br> vtkSmartPointer< vtkVolumeRayCastCompositeFunction >::New();<br>
vtkSmartPointer< vtkVolumeRayCastMapper > volumeMapperMIP =<br> vtkSmartPointer< vtkVolumeRayCastMapper >::New();<br> volumeMapperMIP->SetVolumeRayCastFunction(compositeFunction);<br> volumeMapperMIP->SetInput(readerImageCast->GetOutput());<br>
<br> vtkSmartPointer< vtkVolume > volume =<br> vtkSmartPointer< vtkVolume >::New();<br> volume->SetMapper(volumeMapperMIP);<br> volume->SetProperty(volumeProperty);<br> <br>
vtkSmartPointer< vtkRenderer > renderer =<br> vtkSmartPointer< vtkRenderer >::New();<br> renderer->AddVolume(volume);<br> renderer->ResetCamera();<br><br> ui->mipvolume->GetRenderWindow()->AddRenderer(renderer);<br>
connect(this->ui->updateMIP, SIGNAL(clicked()), this, SLOT(UpdateMIP()));<br><br>Hope you could help me , cuz im really in need of some segmentation method and image threshold seems to be the one for ir.<br><br>
Thx in advance.<br><br>Rodrigo<br><div class="gmail_extra"><br><br><div class="gmail_quote">2012/11/28 shinaji <span dir="ltr"><<a href="mailto:t_shinaji@chiba-u.jp" target="_blank">t_shinaji@chiba-u.jp</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
I usually load CT data (dicom) to the vtkImageData.<br>
Then take threshold it by vtkImageThreshold as a following example.<br>
<br>
reader = vtk.vtkDICOMImageReader()<br>
reader.SetFileName('IM-0013-0399.dcm')<br>
reader.Update();<br>
<br>
src = vtk.vtkImageData()<br>
src.DeepCopy(reader.GetOutput())<br>
<br>
thresh = vtk.vtkImageThreshold()<br>
thresh.SetInput(src)<br>
thresh.SetInValue(32768)<br>
thresh.ThresholdBetween(0, 200)<br>
<br>
bwLut = vtk.vtkLookupTable()<br>
bwLut.SetTableRange(0, 2000)<br>
bwLut.SetSaturationRange(0, 0)<br>
bwLut.SetHueRange(0, 0)<br>
bwLut.SetValueRange(0, 1)<br>
bwLut.Build()<br>
<br>
imageMapToColor = vtk.vtkImageMapToColors()<br>
imageMapToColor.SetInput(thresh.GetOutput())<br>
imageMapToColor.SetLookupTable(bwLut)<br>
imageMapToColor.Update()<br>
<br>
writer = vtk.vtkPNGWriter()<br>
writer.SetFileName('thresh.png')<br>
writer.SetInput(imageMapToColor.GetOutput())<br>
writer.Update()<br>
writer.Write()<br>
<br>
Are these code giving you that you want to do?<br>
<br>
Shinaji<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://vtk.1045678.n5.nabble.com/Segmentation-for-3D-ultrasound-data-set-tp5717312p5717329.html" target="_blank">http://vtk.1045678.n5.nabble.com/Segmentation-for-3D-ultrasound-data-set-tp5717312p5717329.html</a><br>
Sent from the VTK - Users mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<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>
</blockquote></div><br><br clear="all"><br>-- <br><b><font face="'comic sans ms', sans-serif" color="#000066">Rodrigo aka WarHearT</font></b><br>
</div>