[vtkusers] smoothen binarized vtkImageData

Bill Lorensen bill.lorensen at gmail.com
Wed Oct 3 18:46:10 EDT 2018


To interpolate a discrete segmentation you must use nearest neighbor
interpolation.

On Wed, Oct 3, 2018 at 3:17 AM Ang <ysa0829 at gmail.com> wrote:
>
> I want to smoothen binarized vtkImageData like image below from right to left
> <http://vtk.1045678.n5.nabble.com/file/t281986/123132.png>
>
> I followed
> https://stackoverflow.com/questions/45365727/vtk-volume-visualization-issue
> and had results like below
> <http://vtk.1045678.n5.nabble.com/file/t281986/22222.png>
>
> Then I tried using linear interpolation, the colors turned to be abnormal
>
> <http://vtk.1045678.n5.nabble.com/file/t281986/33333.png>
>
> Below are my code pieces:
>
> //Declaring Variables
>         vtkSmartPointer<vtkVolumeProperty> volumeProperty;
>         vtkSmartPointer<vtkPiecewiseFunction> compositeOpacity;
>         vtkSmartPointer<vtkColorTransferFunction> color;
>         vtkSmartPointer<vtkVolume> volume;
>         vtkGPUVolumeRayCastMapper* mapper = vtkGPUVolumeRayCastMapper::New();
>
>         volumeProperty = vtkSmartPointer<vtkVolumeProperty>::New();
>         compositeOpacity = vtkSmartPointer<vtkPiecewiseFunction>::New();
>         color = vtkSmartPointer<vtkColorTransferFunction>::New();
>         volume = vtkSmartPointer<vtkVolume>::New();
>
>         mapper->SetAutoAdjustSampleDistances(0);
>
>         double spacing[3];
>         m_RegionImageData->GetSpacing(spacing);
>
>
>         double distance = spacing[0];
>         if (distance>spacing[1])
>         {
>                 distance = spacing[1];
>         }
>         if (distance>spacing[2])
>         {
>                 distance = spacing[2];
>         }
>         distance = distance / 2.0;
>
>
>
>         mapper->SetSampleDistance(static_cast<float>(distance));
>         volumeProperty->ShadeOn();
>         volumeProperty->SetIndependentComponents(1);
>         volumeProperty->SetInterpolationTypeToLinear();
>         volumeProperty->SetColor(color);
>         volumeProperty->SetScalarOpacity(compositeOpacity);
>     mapper->SetBlendModeToComposite();
>         m_RegionImageData->UpdateCellGhostArrayCache();
>         mapper->SetInputData(m_ReigonGrowing->m_RegionImageData);
>         mapper->SetMaskTypeToLabelMap();
>         mapper->SetMaskBlendFactor(0.8);
>         volume->SetMapper(mapper);
>         volume->SetProperty(volumeProperty);
>         m_cImage3DViewer->getRenderer()->AddViewProp(volume);
>         //Setting Voxel Data and Its Properties
>         compositeOpacity->AddPoint(0, 0);
>         for (int i = 1; i <
> m_ReigonGrowing->m_lookupTable->GetNumberOfTableValues(); i++)
>         {
>
>                 compositeOpacity->AddPoint(i, 1);
>                 color->AddRGBPoint(i, m_ReigonGrowing->m_lookupTable->GetTableValue(i)[0],
> m_ReigonGrowing->m_lookupTable->GetTableValue(i)[1],
> m_ReigonGrowing->m_lookupTable->GetTableValue(i)[2]);
>         }
>
>         m_cImage3DViewer->getRenderer()->ResetCamera();
>
>
> /*m_cImage3DViewer->assignImageToVolume(m_pProjectData->GetActivePatientData()->GetOriginImageDataPtr(),
> m_cImage3DViewer->m_k3DLUT);
>
>         StartAdjustCropRegionWidget();*/
>
> m_cImage3DViewer->getRenderer()->GetRenderWindow()->GetInteractor()->Render();
>
> Does anyone has any ways to smoothen binarized vtkImageData?
>
>
>
> --
> Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html
> _______________________________________________
> 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
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> https://public.kitware.com/mailman/listinfo/vtkusers



-- 
Unpaid intern in BillsParadise at noware dot com


More information about the vtkusers mailing list