Query about overlaying image plots with transparency

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Query about overlaying image plots with transparency

Lee Taylor
I am trying to superimpose two images.  One is a greyscale and the other
is just an array laid out in a grid with values of 0, 1 or 2.  I'd like
to plot 0 as transparent so the image below is visible then plot 1 and 2
as red.  I can plot the image and I can plot the the grid, but when I
try to plot both it is not working.  The entire plot is red instead of
just the grid. I can get two images to plot if one is an RGBA array, but
not when it is an image (from lena)

Attached is an example derived from chaco/examples/demo/image_plot.py

In addition, is this the best way to set up a small color map?

     colors = array([
             enable.colors.color_table['none'],
             enable.colors.color_table['red'],
             enable.colors.color_table['red']
             ])
     rng = DataRange1D(ArrayDataSource(array([0,2])))
     colormap = ColorMapper.from_palette_array(colors, range=rng, steps=3)

There was a similar question on the chaco-users list last year, but
there was no solution.
https://mail.enthought.com/pipermail/chaco-users/2012-February/001760.html

I found another question 'Stacking images and controlling their
transparency in a Traits environment' at
https://mail.enthought.com/pipermail/epd-users/2013-February/001178.html
but that controlled the alpha of the entire image, not just one color.

I also seem to recall a Chaco demo which plotted an image of a metro
station then did some edge detection and was overlaying the plots, but I
was unable to find any references to it today.

Lee Taylor

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev

grey.py (4K) Download Attachment