[vtkusers] Segmentation for 3D ultrasound data set

Rodrigo Lovera lobo.theslayer at gmail.com
Wed Nov 28 23:41:25 EST 2012


Hmnn your code is not working for me, Im trying to do a volume render and
it gives me the following error:

ERROR: In C:\Users\RODRIGO LOVERA\Documents\PUCP\Tesis\VTK
5.10\VTK\VolumeRendering\vtkVolumeRayCastMapper.cxx, line 326
vtkVolumeRayCastMapper (04ADF0A8): Cannot volume render data of type
double, only unsigned char or unsigned short.

ERROR: In C:\Users\RODRIGO LOVERA\Documents\PUCP\Tesis\VTK
5.10\VTK\VolumeRendering\vtkVolumeRayCastMapper.cxx, line 326
vtkVolumeRayCastMapper (04ADF0A8): Cannot volume render data of type
double, only unsigned char or unsigned short.

I think that is probably for the use of vtkImageData.

My code goes as follows:

vtkSmartPointer< vtkDICOMImageReader > reader =
        vtkSmartPointer< vtkDICOMImageReader >::New();
    reader->SetDataByteOrderToLittleEndian();
    reader->SetDirectoryName("C:\\VTK5.10\\DATA\\DICOM");
    reader->SetDataSpacing(3.2, 3.2, 1.5);
    reader->SetDataOrigin(0.0, 0.0, 0.0);
    reader->Update();

    vtkSmartPointer< vtkImageCast > readerImageCast =
        vtkSmartPointer< vtkImageCast >::New();
    readerImageCast->SetInput((vtkDataObject *)reader->GetOutput());
    readerImageCast->SetOutputScalarTypeToUnsignedChar();
    readerImageCast->ClampOverflowOn();

    m_opacityFunction = vtkPiecewiseFunction::New();

    m_colorTransferFunction = vtkColorTransferFunction::New();

    vtkSmartPointer< vtkVolumeProperty > volumeProperty =
        vtkSmartPointer <vtkVolumeProperty >::New();
    volumeProperty->SetColor(m_colorTransferFunction);
    volumeProperty->SetScalarOpacity(m_opacityFunction);
    volumeProperty->ShadeOn();
    volumeProperty->SetInterpolationTypeToLinear();

    vtkSmartPointer< vtkVolumeRayCastCompositeFunction > compositeFunction =
                vtkSmartPointer< vtkVolumeRayCastCompositeFunction >::New();
    vtkSmartPointer< vtkVolumeRayCastMapper > volumeMapperMIP =
        vtkSmartPointer< vtkVolumeRayCastMapper >::New();
    volumeMapperMIP->SetVolumeRayCastFunction(compositeFunction);
    volumeMapperMIP->SetInput(readerImageCast->GetOutput());

    vtkSmartPointer< vtkVolume > volume =
        vtkSmartPointer< vtkVolume >::New();
    volume->SetMapper(volumeMapperMIP);
    volume->SetProperty(volumeProperty);

    vtkSmartPointer< vtkRenderer > renderer =
        vtkSmartPointer< vtkRenderer >::New();
    renderer->AddVolume(volume);
    renderer->ResetCamera();

    ui->mipvolume->GetRenderWindow()->AddRenderer(renderer);
    connect(this->ui->updateMIP, SIGNAL(clicked()), this,
SLOT(UpdateMIP()));

Hope you could help me , cuz im really in need of some segmentation method
and image threshold seems to be the one for ir.

Thx in advance.

Rodrigo


2012/11/28 shinaji <t_shinaji at chiba-u.jp>

> Hi,
> I usually load CT data (dicom) to the vtkImageData.
> Then take threshold it by vtkImageThreshold as a following example.
>
>     reader = vtk.vtkDICOMImageReader()
>     reader.SetFileName('IM-0013-0399.dcm')
>     reader.Update();
>
>     src = vtk.vtkImageData()
>     src.DeepCopy(reader.GetOutput())
>
>     thresh = vtk.vtkImageThreshold()
>     thresh.SetInput(src)
>     thresh.SetInValue(32768)
>     thresh.ThresholdBetween(0, 200)
>
>     bwLut = vtk.vtkLookupTable()
>     bwLut.SetTableRange(0, 2000)
>     bwLut.SetSaturationRange(0, 0)
>     bwLut.SetHueRange(0, 0)
>     bwLut.SetValueRange(0, 1)
>     bwLut.Build()
>
>     imageMapToColor = vtk.vtkImageMapToColors()
>     imageMapToColor.SetInput(thresh.GetOutput())
>     imageMapToColor.SetLookupTable(bwLut)
>     imageMapToColor.Update()
>
>     writer = vtk.vtkPNGWriter()
>     writer.SetFileName('thresh.png')
>     writer.SetInput(imageMapToColor.GetOutput())
>     writer.Update()
>     writer.Write()
>
> Are these code giving you that you want to do?
>
> Shinaji
>
>
>
> --
> View this message in context:
> http://vtk.1045678.n5.nabble.com/Segmentation-for-3D-ultrasound-data-set-tp5717312p5717329.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>



-- 
*Rodrigo aka WarHearT*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20121128/0a27e957/attachment.htm>


More information about the vtkusers mailing list