[vtkusers] smoothen binarized vtkImageData
Ang
ysa0829 at gmail.com
Wed Oct 3 06:17:38 EDT 2018
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
More information about the vtkusers
mailing list