VTK

Excuse me, how to use volume data to achieve 10000X10000X1000 resolution drawing, thank you very much.

What are you trying to achieve? What is the problem you are experiencing?

I use VTK to produce a 3-D model with volum data(102410241024), but I found I cannot deal with volum data(10000100001000). So I want to know how to deal with these big volum data(10000100001000) with VTK. My code are as follows:

#include “vtkSmartPointer.h”
#include “vtkOpenGLGPUVolumeRayCastMapper.h”

#include “vtkPiecewiseFunction.h”
#include “vtkColorTransferFunction.h”
#include “vtkContourValues.h”

#include “vtkInteractorStyleTrackballCamera.h”
#include “vtkMetaImageReader.h”
#include “vtkRenderWindow.h”
#include “vtkRenderWindowInteractor.h”
#include “vtkRenderer.h”
#include “vtkCamera.h”
#include “vtkVolume.h”
#include “vtkVolumeProperty.h”
#include “vtkNamedColors.h”

int main(int argc, char* argv[])
{
vtkSmartPointer reader =
vtkSmartPointer::New();
reader->SetFileName(“FullHead.mhd”); //reader->SetFileName(argv[1]);

auto colorTransferFunction =
    vtkSmartPointer<vtkColorTransferFunction>::New();
colorTransferFunction->RemoveAllPoints();
colorTransferFunction->AddRGBPoint(2, 1, 0, 0);
colorTransferFunction->AddRGBPoint(1, 0, 1, 0); 
colorTransferFunction->AddRGBPoint(0, 0, 0, 1); 

auto scalarOpacity =
    vtkSmartPointer<vtkPiecewiseFunction>::New();

scalarOpacity->AddPoint(2, 0);
scalarOpacity->AddPoint(1, 0.5); 
scalarOpacity->AddPoint(0, 1); 

auto volumeProperty =
    vtkSmartPointer<vtkVolumeProperty>::New();
volumeProperty->ShadeOn();
volumeProperty->SetInterpolationType(2);

volumeProperty->SetColor(colorTransferFunction);
volumeProperty->SetScalarOpacity(scalarOpacity);

auto mapper =
    vtkSmartPointer<vtkOpenGLGPUVolumeRayCastMapper>::New();
mapper->SetInputConnection(reader->GetOutputPort());
mapper->AutoAdjustSampleDistancesOff();
mapper->SetSampleDistance(0.5);
//mapper->SetBlendModeToIsoSurface();

//volumeProperty->GetIsoSurfaceValues()->SetValue(0, 128);
//volumeProperty->GetIsoSurfaceValues()->SetValue(1, 255);

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

auto colors =
    vtkSmartPointer<vtkNamedColors>::New();

auto renderer =
    vtkSmartPointer<vtkRenderer>::New();
renderer->AddVolume(volume);
renderer->SetBackground(colors->GetColor3d("white").GetData());
renderer->ResetCamera();

auto renderWindow =
    vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->SetSize(800, 800);
renderWindow->AddRenderer(renderer);

auto style =
    vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();

auto interactor =
    vtkSmartPointer<vtkRenderWindowInteractor>::New();
interactor->SetRenderWindow(renderWindow);
interactor->SetInteractorStyle(style);

// Generate a good view
vtkSmartPointer<vtkCamera> aCamera =
    vtkSmartPointer<vtkCamera>::New();
aCamera->SetViewUp(0, 0, -1);
aCamera->SetPosition(0, -1, 0);
aCamera->SetFocalPoint(0, 0, 0);

renderer->SetActiveCamera(aCamera);
renderer->ResetCamera();

aCamera->Azimuth(30.0);
aCamera->Elevation(30.0);
aCamera->Dolly(1.5);
renderer->ResetCameraClippingRange();

renderWindow->Render();

interactor->Start();

return EXIT_SUCCESS;

}

This is a rather large volume for volume rendering. If you find that your graphics card cannot deal with it then you can upgrade your hardware or resample and/or crop the image. If your GPU memory size is big enough and you just exceed the maximum texture size then you can try to adjust partitions size - see this topic: Volume rendering invalid texture dimensions.

Thank you very much.