Re: Display RGB values / P4_09

Hello,

Detlef Gaisser wrote:
Hello
I'm trying to Display RGB values in a Color Cube like in Example P4_09, with the
difference that i already have the RGB Values in a 3 dimensional array.
(e.g [255,255,0] should map to yellow and should be displayed as 255,255,0).

Program 4-09 is called Color CubeS, rather than Color Cube. Subtle, but important difference ;-)

I think you probably want example 4-08. Try something like

(x,y,z) -> (value)

Using a 3D domain set and setting the samples with

  int value = 0;

  for(int l = 0; l < NLEVS; l++)

    for(int c = 0; c < NCOLS; c++)

      for(int r = 0; r < NROWS; r++){

            // set rgbVal values
            flat_samples[0][ value ] =   value

            value++;
    }

more or less like it's done in example 4-08. Then use a ColorControl and a colour table like

myColorTable = new float[][]{{0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f}, // red component {0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f}, // green component {0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f}}; // blue component



(also refer to example 4-04 and 4-05: http://www.geogr.uni-jena.de/~p6taug/visad/tutorial/s4/Section4.html#section4_4)

and set it with:

ColorControl colCont = (ColorControl) yourRGBMap.getControl();

colCont.setTable( myColorTable );

yourRGBMap is a map like

yourRGBMap = new ScalarMap(value, Display.RGB);

Note that you'll have to convert your int values to floats (I mean the colour table values), e.g.

  public float[][] normalize(float[][] tableIn_0_255){
    // construct a new table, if you want...
    // skip... code for doing that

    for (int i = 0; i < tableIn_0_255.length; i++) {
      for (int j = 0; j < tableIn_0_255[0].length; j++) {
        tableIn_0_255[i][j] = tableIn_0_255[i][j] / 255f;
      }
    }

    return tableIn_0_255;
  }


I looked at also at the other examples, but couldn't find a good way to achieve
this.

Thanks for any hint.

Detlef



I hope that helps.

Grüsse,

Ugo


  • 2003 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: