How do I create a pseudo-color image in C++?
<p>I have an array of pixels with an associated intensity (as a float between 0 and 1) that I would like to convert to a RGB image.</p>

<p>The easiest way would be to just multiply each value by 255 and assign it to R+G+B to obtain a greyscale image, but I think it would be better to use a whole range of colors to show finer differences.</p>

<p>As far as I know this is called a pseudo/false color image, but I am having a hard time finding algorithms for it. Right now I am using this code, but I was wondering if there was a smarter/faster way to do it:</p>

<pre><code> if(intensity &lt;= 0.25) {
  p-&gt;r = 0;
  p-&gt;g = 0;
  p-&gt;b = (intensity) * 4 * 255;
  return;
 }

 if(intensity &lt;= 0.5) {
  p-&gt;r = 0;
  p-&gt;g = (intensity - 0.25) * 4 * 255;
  p-&gt;b = 255;
  return;
 }

 if(intensity &lt;= 0.75) {
  p-&gt;r = 0;
  p-&gt;g = 255;
  p-&gt;b = (0.75 - intensity) * 4 * 255;
  return;
 }

 if(intensity &lt;= 1.0) {
  p-&gt;r = (intensity - 0.75) * 4 * 255;
  p-&gt;g = (1.0 - intensity) * 4 * 255;
  p-&gt;b = 0;
  return;
 }
</code></pre>

<p>Also, are there any standard color palettes I should use for this? </p>
