[vtkusers] [vtk-users] urgent! range image as double

David Gobbi david.gobbi at gmail.com
Fri May 6 08:43:09 EDT 2016


Hi Bruno,

This looks like a mistake:

   auto rawData = filter->GetOutput();

You need the output from vtkImageShiftScale (and you need to update first):

  scale->Update();
  auto rawData = scale->GetOutput();

 - David


On Fri, May 6, 2016 at 6:28 AM, Bruno Oliveira <
bruno.manata.oliveira at gmail.com> wrote:

> 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();
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160506/b8d1a5a3/attachment.html>


More information about the vtkusers mailing list