Integer truncation in data value color mapping can cause duplicate colors in lookup table
When mapping a data value to an index in a color map in vtkLinearIndexLookupMain in vtkLookupTable.cxx, the floating point result can fall just below the integral value to which it ought to be mapped. See specifically the following starting at vtkLookupTable.cxx:548.
double dIndex = (v + p.Shift) * p.Scale; // When v is very close to p.Range, the floating point calculation giving // dIndex may map above the highest value in the lut (at index p.NumColors-1) // in the linear mapping above. This is why we keep an extra copy of the last // lut value, to avoid extra work in this very hot function. // It should never be more than 1 off, assert to be sure. index = static_cast<vtkIdType>(dIndex); assert(index >= 0 && index <= p.NumColors);
This can lead to duplicate colors when creating a color map, as is exhibited in this color legend:
See the duplicate blues between values 1441.1 and 1443.6.
This could be addressed by rounding the mapped data value to the nearest integer.