# Display data with a "preset" LookupTable

**URL:** https://discourse.vtk.org/t/display-data-with-a-preset-lookuptable/7139
**Category:** Support
**Created:** [November 10, 2021, 3:27pm UTC](https://discourse.vtk.org/t/display-data-with-a-preset-lookuptable/7139 "2021-11-10T15:27:18Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Olivier](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/o/d2c977/32.png) [@Olivier](https://discourse.vtk.org/u/Olivier)
#### Post date: [November 10, 2021, 3:27pm UTC](https://discourse.vtk.org/t/display-data-with-a-preset-lookuptable/7139/1 "2021-11-10T15:27:18Z")

</div>

Hi,

In ParaView & VTK.js, there are several Color table presets (stored in ColorMaps.json), and functions to transform these presets into valid LookupTables.

I’ve tried to replicate those codes into classic C++ API, but cannot achieve the desired result.  
I simply want to make a valid LookupTable to pass to my Mapper, starting from the values inside ColorMaps.json.

My current code looks like :

```auto
auto preset = Preset["jet"]; // jet is a double[] with values from RGBPoints
vtkNew<vtkColorTransferFunction> xfer;
for (int i=0; i<preset.length/4; i++) xfer->AddRGBPoint(preset[4*i+0], preset[4*i+1], preset[4*i+2], preset[4*i+3]));
xfer.Build();

vtkNew<vtkLookupTable> table;
table->SetNumberOfTableValues(256);
for (int i=0; i<256; i++)
{
	auto rgb = new double[3];
	xfer->GetColor(n / 256.0, rgb);
	table->SetTableValue(i, rgb[0], rgb[1], rgb[2], 1);
});
surfaceTable.Build();

```

This code actually works when the chosen Preset has X values range [0 … 1].  
When Preset has [-1 … +1], for example “JET”, the code is obviously not good.  
I can of course look at Preset actual range and change the second for loop accordingly, but I wonder if there was better / simpler ways to achieve some kind of automatic translation from vtkColorTransferFunction to vtkLookupTable ?

Thanks !
