Problem in volume Rendering. Noise added automatically

(marefin@uwo.ca) #1

Hi,

I have been trying to render a custom volume in vtk, but it is showing a lot of statics (random values). I have tried many options with no avail. Here is my code snippet.

for (int k = 0; k < existingVolDims[2]; k++){ // rows
for (int j = 0; j < existingVolDims[1]; j++){ // cols
for (int i = 0; i < existingVolDims[0]; i++){ //deps
// Put old value into new voxel location
newVoxVal = static_cast<char*>(newVolumeImageData->GetScalarPointer(i, j, k));
oldVoxVal = static_cast<char*>(currVolumeImageData->GetScalarPointer(i, j, k));
oldVoxValint = static_cast(oldVoxVal[0]);
// If the location is empty, only then transfer the old value to it. Otherwise, new location remains empty.
if (oldVoxValint > 0){
newVoxVal[0] = oldVoxVal[0];
//newVoxVal[1] = oldVoxVal[1];
//newVoxVal[2] = oldVoxVal[2];
}
else{
newVoxVal[0] = static_cast(255);
}
}
}
}

    compositeOpacity->AddPoint(0, 0.0);
compositeOpacity->AddPoint(80, 1.0);
compositeOpacity->AddPoint(80.1, 0.0); // compositeOpacity->AddPoint(150, 1.0);
compositeOpacity->AddPoint(255, 0.0);

volumeProperty->SetInterpolationType(2);
volumeProperty->SetScalarOpacity(compositeOpacity);
volumeProperty->SetAmbient(0.1);
volumeProperty->SetDiffuse(0.9);
volumeProperty->SetSpecular(0.2);
mapper->SetInputData(currVolumeImageData);
mapper->SetBlendModeToComposite();
volume->SetMapper(mapper);
volume->SetProperty(volumeProperty);
renderer->AddViewProp(volume);
ui->view->GetRenderWindow()->AddRenderer(renderer);

Capture

Please note in the image attached that the volume is rendering, but all these static noise is also getting added. I do not know where they are coming from. Could you please help me figure out the problem?

Sincerely
Arefin

(Andras Lasso) #2

Probably you need to adjust the transfer functions to make the background noise voxels transparent. You can use 3D Slicer, ParaView, MITK, or other 3D visualization applications that have built-in transfer function editor with real-time display.

(marefin@uwo.ca) #3

Hi Andras, Thank you for your response. It totally makes sense that I need to setup an appropriate transfer function. Unfortunately, for my project I am unable to use the existing software, as my code generates the volume based on the algorithms I wrote. Could you please refer me to any documentation or sites that could help me setup the transfer function.

(Andras Lasso) #4

You can use existing interactive software to explore what transfer functions work well and then in your custom application you can use a simplified GUI to slightly adjust them. Usually a few sliders are enough that move a few key transfer functions points.

All the software that I recommended above is fully customizable and extensible. You can add your custom algorithms as plugins and leverage the enormous amount of software development effort that were invested into these software.

(marefin@uwo.ca) #5

Hi Andras, Thank you so much for your suggestions. I was able to use both 3D slicer and ParaView to diagnose the issue with my transfer function. Apparently, CHAR type sometimes give rise to noise problem in volume rendering. When I saved the produced volume in INT type in Slicer, I was able to make the necessary changes to reconstruct the volume. Attached is the working model. Hopefully, this response helps someone in future.Capture

1 Like