[vtkusers] [vtk-users] urgent! range image as double
Bruno Oliveira
bruno.manata.oliveira at gmail.com
Fri May 6 08:28:28 EDT 2016
Hello,
I need to get the zbuffer in double or single precision float. This is what
I'm doing
renderWindow->Render();
vtkSmartPointer<vtkWindowToImageFilter> filter =
vtkSmartPointer<vtkWindowToImageFilter>::New();
vtkSmartPointer<vtkImageShiftScale> scale =
vtkSmartPointer<vtkImageShiftScale>::New();
// Filter Object Setup
filter->SetInput(renderWindow);
filter->SetMagnification(1);
filter->SetInputBufferTypeToZBuffer(); //Extract z buffer value
filter->ReadFrontBufferOff(); // read from the back buffer
filter->Update();
// Scale Object Setup
scale->SetOutputScalarTypeToDouble();
scale->SetInputConnection(filter->GetOutputPort());
scale->SetShift(0);
auto rawData = filter->GetOutput();
rawData->Register(nullptr); // !!! Increase reference counter, make
returned Image struct
// responsible for freeing the memory
afterwards
int dims[3];
// Returns coords in (x, y) instead of (row, col)
rawData->GetDimensions(dims);
assert(rawData->GetNumberOfScalarComponents() == 1);
double *rawData = rawData->GetScalarPointer();
However, this is causing a segmentation fault. What am I doing wrong?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160506/bf6cadfa/attachment.html>
More information about the vtkusers
mailing list