visit-dav / visit

VisIt - Visualization and Data Analysis for Mesh-based Scientific Data
https://visit.llnl.gov
BSD 3-Clause "New" or "Revised" License
429 stars 111 forks source link

Do we really need two flavors of color tables #17832

Open markcmiller86 opened 2 years ago

markcmiller86 commented 2 years ago

We have a notion of Continuious and Discrete color tables. Why? Whats the difference? We essentially allow either to be used for discrete and continuous data. So, what value is there in having this difference manifested in our GUI/CLI.

Why not just have color tables with...

That last item (a boolean) is what creates the fundamental difference between continuous coloring and discrete coloring. I just don't think that has to manifest as buttons and functions in our GUI and CLI.

JustinPrivitera commented 2 years ago

Could there be a button or checkbox to toggle between making your color table continuous or discrete? So it would control that boolean you mentioned in the last bullet point up above?

JustinPrivitera commented 2 years ago

https://visit-sphinx-github-user-manual.readthedocs.io/en/develop/using_visit/MakingItPretty/Color_tables.html#converting-color-table-types

JustinPrivitera commented 2 years ago

I'd like to mention that having two flavors of color tables has lead to considerable headache with implementation. :(

markcmiller86 commented 2 years ago

I am fairly certain we don't need two flavors. At the end of the day, a color table is nothing more than a list of colors (and possibly opacities, and possibly positions in the range [0,1]) Thats all a color table is. Whether the colors from that table are interpolated (continous) or not (discrete) has to do with how the color table is used in any given context.

markcmiller86 commented 2 years ago

Some observations

From a set of K color control points (rgb + alphas/opacities + positions in [0,1]) we define N colors.

When the table is discrete, N=K and the colors in the tabel are 1:1 with the control points. When the table is continuous, N is 256 and N colors are interpolated among the K control points. For a discrete color table, the positions are implied and are uniform over [0,1]. For a continous color table, the positions are arbitrary but are often uniform.

When a discrete color table is used to color lists of things (materials, subsets, domains), Q items are numbered 0...Q-1. When the Q items are mapped by a discrete table, they are assigned such that the next item in the set gets the next color in the table but where next can wrap-around to the beginning of the table if Q > N as it often is. (As an aside, I find myself wondering if we could add four-color-theorem like logic to optimize our use of small numbers of colors for 2D meshes or its extension for 3D and do a much better job ensuring thins are distinguishable. When the Q items are mapped by a continuous table, the items are treated like any continuous variable with range 0...Q-1.

Interpolation between color control points works best only for color control points that are near each other in color space. When color control points are not near (enough to) each other, interpolation between adjoining color control points results in odd bright/dark banding effects (maybe we need a better color-space interpolation scheme to address this. I'd bet we're interpolating in RGB space but should instead be interpolating in YiQ space or maybe HSV). But, currently, this means that not all sets of color control points are suitable/best for continous color tables.

Color control points being near each other is actually a feature we want to avoid when coloring list of things because we want items which neighbor each other in physical space but which are different items to be distinctly colored to increase the likelihood that their boundaries are distinguishable in physical space.

Continous color tables have three possible interpolation schemes...

The color table button of any plot allows user to select either a discrete table or a continuous table for any data.

The legend of a plot has hard (well defined, banded) boundaries between neighboring values for discrete color tables or for continuous color tables with no interpolation or for continuous color tables applied to lists of objects. Lists of objects plot's legends are always banded regardless of whether continuous or discrete color table is in use...which makes sense.

markcmiller86 commented 2 years ago

From the above, color tables are just lists of color control points which have names (and now tags to help sort among the many possibilities).

When a table is used in a plot, a handful of additional questions arise in how those color control points are ultimately used to color the plot. I wonder if this handful of additional questions represents an intermediate level control object in the interface...a coloring strategy.

Having these controls in a new coloring strategy control or maybe just flat additional controls at the plot's interface means that you don't wind up defining 3 different color tables with largely the same set of control points but with different settings affect different colorings using what amounts to the same table.