Re: transparent colours for filling contours? [message #26225] |
Wed, 15 August 2001 06:03 |
ngls
Messages: 10 Registered: November 2000
|
Junior Member |
|
|
I've done vaguely similar things trying to blend a solid-colour (bitmap)
image with a grey-scale image, such that the grey-scale would show through.
I did this by creating the two plots separately, taking (bitmap) images of
the plots, converting these plots to HSL colours (from RGB colours) and
then modifying the "L" (lightness) value of the colour image.
For instance, you could multiply the L values by 1.5 (say) to wash out the
colours (if need be) and then divide by the grey-scale image to darken the
colour image where the plot lines were drawn. If you had blacks or dark
colours in the colour image you might have to add a constant (0.25 say) to
the L values to wash out the colours, and then check for L>1.0
Of course, this only works with bitmap images of the plots and so restricts
print quality. No doubt you could do all this much more directly with
object graphics (no pun intended).
The code below might give you an idea of what I mean.
Good Luck.
Justin
PRO test_colour_merge
;Merges a black and white plot, with a colour image
DEVICE, DECOMPOSED=0
;Make some data to plot
z = SHIFT(DIST(50,50), 25, 25)
z = SIN(z*2*!PI/max(z))
x = FINDGEN(1000)*2*!PI/1000
LOADCT, 0 ;Load grey-scale colours
;The COLOR value determines how dark/light the plot lines appear
PLOT, x, SIN(x), BACKGROUND=255, COLOR=64
img_grey = TVRD()
;Now do the colour
LOADCT, 34 ;load rainbow colors
SHADE_SURF, z ;Could probably use IMAGE keyword
img_colour = TVRD(True=1) ;get the true-colour values
;Convert RGB colours to Hue, Lightness, Saturation
COLOR_CONVERT, img_colour[0,*,*], img_colour[1,*,*], $
img_colour[2,*,*], newH, newL, newS, /RGB_HLS
;newL = newL * 1.5 ;Wash colours by multiplication
newL = newL + 0.25 ;Wash out colours by addition
newL = newL * (img_grey/255.) ;Darken where the plot lines are
;newL = newL / (img_grey/255.) ;Lighten plot lines
;Check for L>1.0 in case of L addition
list = WHERE(newL GT 1.0, count)
if count GT 0 THEN newL[list]=1.0
;Convert back to RGB ready for display
COLOR_CONVERT, newH, newL, newS, R, G, B, /HLS_RGB
LOADCT,0 ;return to grey-scale ready for true-colour
DEVICE, DECOMPOSED=1
;Display the latest image
TV, [R,G,B], TRUE=1
END
ahw199@soton.ac.uk (Ann Webber) wrote in
<b73826cc.0108140426.18c18654@posting.google.com>:
> Hi,
> I am plotting contours over a map and I was wondering if there was a
> way of filling the contours so that I can still see the map
> underneath? i.e. I want to be able to see country boundaries
> underneath the filled contours. Is there a colour table that contains
> sone transparent colours? Or is this completely impossible to do?
> Regards
> Ann Webber
|
|
|
Re: transparent colours for filling contours? [message #26228 is a reply to message #26225] |
Tue, 14 August 2001 06:06  |
david[2]
Messages: 100 Registered: June 2001
|
Senior Member |
|
|
Ann Webber writes:
> I am plotting contours over a map and I was wondering if there was a
> way of filling the contours so that I can still see the map
> underneath? i.e. I want to be able to see country boundaries
> underneath the filled contours. Is there a colour table that contains
> sone transparent colours? Or is this completely impossible to do?
Typically, the country boundaries are placed on
top of the filled contours so they can be seen
(I.e., the Map_Continents and/or Map_Grid commands
are used after the Contour command).
But it is possible to make semi-transparent colors by
pixelating the colors, so that only half of them are
drawn, allowing the colors underneath to show through.
You can see an example in this article:
http://www.dfanning.com/tips/color_overlay.html
But this would be a heck of a lot of work for a
filled contour plot, and I'm not sure the results
would justify the effort. The country lines are
almost sure to look too washed out.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|