Creating a variable length color lookup table

I was wondering if anyone has any tips or can point to good resources related to creating color search tables for image synthesis. In my application, I have floating point values ​​between -1.0 and 1.0 that need to be mapped to RGB space. The problem is that I don’t know in advance how accurate these floating point values ​​will be, so I don’t know how many records are inserted into the lookup table or what they should be. Are there generally accepted methods for processing map data in this form for colors? It seems to be too expensive to create a new color table for each image based on the range of values ​​in the image data area.

I think defining a range of values ​​to display will work, but give me your thoughts. Also, if anyone knows any existing tools (preferably python based) for creating color search tables that would be useful.

+3
source share
2 answers

The term you are looking for is a false color image .

How to choose colored stripes depends on what you are trying to show. A simple way is to split the data into two halves, above and below the average range

= 0, = (255 - ), = ( ). .

= 0, = , = 255- ( ), , .

,

+1

, , .

; , float RGB? (. "" http://jk.ozlabs.org/projects/lca2008-hackfest/).

, HSV RSB Saturation Value Hue. RGB:

i to RGB conversion

. http://jk.ozlabs.org/blog/post/65/hackfest08-solution-2/ , .

C, python. , , 0 <= <= 1, , , , -1 <= <= 1:

/* for a value x (which is between x_min and x_max), interpolate a y value
 * (between y_min and y_max) of the same proportion.
 */
static float interpolate(float x, float x_min, float x_max,
        float y_min, float y_max)
{
    x = (x - x_min) / (x_max - x_min);
    return x * (y_max - y_min) + y_min;

}

/*
 * given a the i and i_max values from a point in our (x,y) coordinates,
 * compute the colour of the pixel at that point.
 *
 * This function does a simplified Hue,Saturation,Value transformation to
 * RGB. We take i/i_max as the Hue, and keep the saturation and value
 * components fixed.
 */
void colour_map(struct pixel *pix, float i, float i_max)
{
    const float saturation = 0.8;
    const float value = 0.8;
    float v_min, hue;

    hue = i / (i_max + 1);
    v_min = value * (1 - saturation);

    /* create two linear curves, between value and v_min, of the
     * proportion of a colour to include in the rgb output. One
     * is ascending over the 60 degrees, the other descending
     */

    if (hue < 0.25) {
        pix->r = value * 255;
        pix->g = interpolate(hue, 0.0, 0.25, v_min, value) * 255;
        pix->b = v_min * 255;

    } else if (hue < 0.5) {
        pix->r = interpolate(hue, 0.25, 0.5, value, v_min) * 255;
        pix->g = value * 255;
        pix->b = v_min * 255;

    } else if (hue < 0.75) {
        pix->r = v_min * 255;
        pix->g = value * 255;
        pix->b = interpolate(hue, 0.5, 0.75, v_min, value) * 255;

    } else {
        pix->r = v_min * 255;
        pix->g = interpolate(hue, 0.75, 1.0, value, v_min) * 255;
        pix->b = value * 255;
    }

    pix->a = 255;
}
+1

Source: https://habr.com/ru/post/1759142/


All Articles