[Image-SIG] Transparent colored overlay effect

Roger Burnham rburnham@cri-inc.com
Tue, 29 Sep 1998 11:19:58 -500


Howdy all,

I'm implementing a principal component analysis of multivariate images 
application (same sample taken at multiple wavelengths) and need help in 
achieving a desired effect.

From various computed images, the user selects regions, each of which identifies 
certain pixels in another computed image.  This later image I'll call the overlay 
image.  I would like to render the overlay image with the identified pixels 
"shaded" a selected color;  i.e. you can still see the gray-scale intensities 
thru a "tinged" color (I've seen this in other commercial apps...).

Currently, all I can achieve is to draw these pixels in opaque colors as follows:

   The overlay image is a gray scale image scaled so that all pixel values are 
between 0 and 255 - (max number of possible colored overlays), then converted to 
an RGB image.

   Then, given a list of masks (255 at the pixels of interest, 0 everywhere else) 
and colorLut[3] (the 256 gray scale ramp):

            lut = copy.copy(colorLut[3])
            rlut, glut, blut = lut[:256], lut[256:512], lut[512:]

            i = 0
            for img in self.masks:
                nV = 255 - i
                pasteImg = img.point(lambda p,nV=nV: p==255 and nV)
                overlayImg.paste(pasteImg, mask=img)
                rlut[nV], glut[nV], blut[nV] = rgb(_overlayColorsUsed[i])
                i = i + 1

            newImg = overlayImg.point(rlut+glut+blut)

newImg now shows the original image with each mask showing in an opaque color.

Any ideas on how I can get the overlain masks to be "slightly" transparent so 
that the underlying gray scale intensities are still discernable?

Thanks,

Roger Burnham
rburnham@cri-inc.com
Cambridge Research & Instrumentation
www.cri-inc.com