[vtkusers] Printing the contents of a vtkWindowLevelLookupTable

Eva Monclús emonclus at cs.upc.edu
Wed Jul 18 07:20:08 EDT 2018


Hello everyone,

I'm working with a volume dataset which is visualized using a 
vtkWindowLevelLookupTable   with a vtkImageMapToColors which takes as an 
input vtkExtractVOI->GetOutputPort(). The vtkExtractVOI has as an 
inputdata the volume dataset.

This pipeline works fine. I can change the window/level of the 
vtkWindowLevelLookupTable  using  SetWindow/SetLevel methods and after 
that I always execute the Build method of the 
vtkWindowLevelLookupTable.   As I said, the changes in the window/level 
are properly mapped in the obtained visualization.

My problem starts when I try to print the colors of the 
vtkWindowLevelLookupTable  (I want to use them in another task).

I use the following code to print it, but I always obtain the same 
values (although I'm changing the window/level and I see how my changes 
affect the current rendering). But, although I change the window/level 
the printed messages are always the same.

void printVtKTransferFunction(vtkLookupTable *vtk_tf)
{
     vtkIdType tv = vtk_tf->GetNumberOfTableValues();
     double dR[2];
     vtk_tf->GetTableRange(dR);
      cout << "Number of table values : " << tv << "\nTable Range: " << 
std::fixed  << std::setw(8) << std::setprecision(6)
                 << dR[0] << " to " << dR[1] << std::endl;
             std::vector<double> indices;
             for (int i = 0; i < tv; ++i)
             {
                 indices.push_back((dR[1] - dR[0]) * i / tv + dR[0]);
             }
             unsigned int id_tf = 0;
             for (std::vector<double>::const_iterator p = 
indices.begin(); p != indices.end(); ++p, id_tf++)
             {
                 double rgba[4];
                 vtk_tf->GetColor(*p, rgba);
                 rgba[3] = vtk_tf->GetOpacity(*p);
                 cerr << id_tf << " : " << rgba[0] << " " << rgba[1] << 
" " << rgba[2] << " " << rgba[3] << endl;
             }
         }
}

Any help will be welcome.  Thank you very much in advance,

    Eva





More information about the vtkusers mailing list