I would think the normal approach would be to use a fragment shader to do a texture lookup, using your 16-bit colors brightness values as the texture coordinate. That would allow a totally arbitrary mapping between input brightness and output color.

On Sat, Feb 11, 2012 at 10:26 AM, Mike C. Fletcher <mcfletch@vrplumber.com> wrote:
On 12-02-10 05:33 PM, Derakon wrote:
> I have a program that displays monochrome camera images, obtained as
> Numpy arrays of 16-bit integer pixel brightnesses. I'd like to have a
> false-color mode that displays low values as blue and high values as
> red, to get some extra contrast and make it easier to tell where the
> brightest pixels in the image are. I did some searching around and
> about all I can find is some discussion on using color-index mode,
> with concern that it's really meant for palettized sprites and isn't
> really recommended these days. Is that accurate?
> Presumably this task has been done before; what's the recommended way
> to do false color? Especially, I want to be able to rescale what value
> is considered the darkest and what the brightest on the fly -- for
> example, if I get an image where the distance between darkest and
> brightest pixel is only 1000 (~10 bits) then I don't want to be
> scaling things as if the brightest pixel is 2^16-1 and the darkest is
> 0.
> Any advice would be recommended. Thanks.
Why not simply do the scaling in the numpy array?  That is, to increase
the dynamic range array = array - min( array); array = array *
(2**16-1/max(array)) (sorry if I messed up the numbers there, hopefully
you get the idea, I have a two year old yelling in my ear at the
moment).  To do the false-color, you can use a shader, or just duplicate
the data into RGB channels. Indexed-color mode is pretty poorly
tested/supported these days; it may work, but I can't say I've used it
in the last decade or so.


  Mike C. Fletcher
  Designer, VR Plumber, Coder

Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
PyOpenGL Homepage
PyOpenGL-Users mailing list