0

Sorry. Im new here at stackoverflow. I am working with Self-Organizing Maps (SOM) which deals with projecting a high dimensional data in a 2D plane where each "nodes" or boxes in this plane contains weights that are relatively small in values ranging from 0 to 1.

Here is an example of the lattice or matrix produced that I want to color with RGB values.

SOM Lattice

For example, a box in the illustration contains weights like

[0.000124, 0.000000004, 0.999923, 0.119999220, 0.999311, 0.000552, 0.00000001223, 0.00045, 0.00001132, 0.99999998211, 0.00000000000000008821]

My algorithm ONLY tries to consider the FIRST THREE VALUES

this.setNodeColor(new Color((int)this.getDoubleElementAt(0) * 255,(int)(this.getDoubleElementAt(1)*255),(int)(this.getDoubleElementAt(2)*255))) 

and this algorithm produces the illustration above.

Each boxes in the lattice has its own weights like what I have posted above. Now consider the given vector above. That is the value of the first BOX row 0, column 0 in the lattice.

Maybe you are wondering why did it has a BLUE color. The reason is that when you plug in the 3 first values of the vector which is approximately (0, 0, 1) on RGB, it produces a BLUEISH color as 0.999923 x 255 = 254 so it seems (0, 0, 254).

Now I do want to utilize all the weights of a node to produce a color for the BOX so that it produces variations on the colors like below.

SOM Lattice 2

I am also aware that I think, the values are so small I need some NORMALIZATION.

I want to ask any idea on how to - NORMALIZE the values - USE all WEIGHTS to come up with a color to paint the NODE. (more important)

Thank you. Feel free to ask for any more clarifications.

Mad Physicist
  • 107,652
  • 25
  • 181
  • 264

1 Answers1

0

To normalize the values, you can scale to a number larger than 255. You can convert the example you provided and rewrite it as

int normalization = 10;
int r = (int)this.getDoubleElementAt(0) * 255 * normalization;
int g = (int)this.getDoubleElementAt(1) * 255 * normalization;
int b = (int)this.getDoubleElementAt(2) * 255 * normalization;
this.setNodeColor(new Color((r > 255) ? 255 : r,
                            (g > 255) ? 255 : g,
                            (b > 255) ? 255 : b));

This will make your faint color components 10 times brighter. The bright components will saturate, but they are close to doing that anyway. Saturated components will get clipped by the ternary operator ?:.

Mad Physicist
  • 107,652
  • 25
  • 181
  • 264
  • Using that code, it became like this, [link](http://imgur.com/a/vbCec) and the original one is like this [link](http://imgur.com/a/5dI9v). – James-Andrew Sarmiento Feb 07 '17 at 16:37
  • @James-AndrewSarmiento. You should play around with the value of `normalization` based on your actual data. I do not have access to it so I can not do it for you. It looks like 10 is not large enough for your case. Also, consider using a separate normalization for each channel if the range of values for each one is consistent. For example, it looks like you would always want a higher normalization for red than you do for green and blue. – Mad Physicist Feb 07 '17 at 16:47