comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Alpha blending with object graphics - different color palettes do not work
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Alpha blending with object graphics - different color palettes do not work [message #75780] Wed, 04 May 2011 09:43 Go to next message
djh is currently offline  djh
Messages: 1
Registered: May 2011
Junior Member
On May 4, 4:11 am, LNpellen <lnpel...@gmail.com> wrote:

> This is how I create the alphaDose:
> alphaDose = BYTARR(2, size[0], size[1], /NOZERO)
> alphaDose[0,*,*]=dose
> alphaDose[1,*,*]=255*alpha ; where alpha is a factor between 0 and 1

I ran into this last year.

Try converting alphaDose into a [4,n,m] array to use in the overlay
image:

alphaDose = Reform( alphaDose, [1, size[0], size[1] ], /overwrite )
oPaletteDose->GetProperty, red_values = r, green_values = g,
blue_values = b
alphaDose4 = [ r[alphaDose], g[alphaDose], b[alphaDose], alphaDose ]
alphaDose4[3,*,*] = 255*alpha

The background image can still use the palette.

Don
Re: Alpha blending with object graphics - different color palettes do not work [message #75782 is a reply to message #75780] Wed, 04 May 2011 09:33 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Karl writes:

> As far as being in indexed mode goes, I don't think that the
> DECOMPOSED setting affects the way IDLgrWindows are created. (not
> sure). But you don't need to have an Indexed destination to use
> palettes in images.

Right. Nor do you want to use indexed color if you work
with Coyote Graphics image commands, although these commands
are a little more tolerant of conservative scientists
who learned to program in the 1970s and will let you
get away with it. Internally, though, the Coyote Graphics
commands *always* work in decomposed color if it is at
all possible. (It's not always possible, except on versions
of IDL starting in IDL 7.1 and higher.)

This is more or less the reason cgImage can display
images with alpha channels and with image transparency.

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Alpha blending with object graphics - different color palettes do not work [message #75784 is a reply to message #75782] Wed, 04 May 2011 09:17 Go to previous messageGo to next message
Karl[1] is currently offline  Karl[1]
Messages: 79
Registered: October 2005
Member
On May 4, 6:30 am, David Fanning <n...@idlcoyote.com> wrote:
> LNpellen writes:
>> Why isn't the rainbow (LoadCT, 13) working for me?
>
> I would guess because you are using indexed color mode.
> You do not EVER want to use indexed color when you are
> working with object graphics.
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.idlcoyote.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")


The IDL docs for IDLgrImage say this for the image data parm:

"An n x m greyscale image, or a 2 x n x m, n x 2 x m, or n x m x 2
greyscale image with an alpha channel. (The alpha channel is ignored
if the destination device uses indexed color mode.)"

So this is considered a Luminance-Alpha image. The first channel is a
luminance (greyscale) channel. Greyscale images do not perform color
lookup through a palette. That is why setting the palette to rainbow
had no effect.

Is the dose map going to be displayed with a constant alpha, or a per-
pixel alpha, where the alpha value could be different for each pixel?

It *looks* like you want a constant alpha because you are filling the
alpha channel of the dose image with a constant (alpha * 255). You
don't need alpha data in the image if you want to apply constant alpha
with the ALPHA_CHANNEL property.

If the alpha is constant, you should just go back to a single channel
image and use that as an "indexed image" in conjunction with the
palette and use the ALPHA_CHANNEL property to set the global constant
alpha to 0.5 or whatever.

That should display your dose image with the color palette and half-
transparent.

As far as being in indexed mode goes, I don't think that the
DECOMPOSED setting affects the way IDLgrWindows are created. (not
sure). But you don't need to have an Indexed destination to use
palettes in images.
Re: Alpha blending with object graphics - different color palettes do not work [message #75788 is a reply to message #75784] Wed, 04 May 2011 05:30 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
LNpellen writes:

> Why isn't the rainbow (LoadCT, 13) working for me?

I would guess because you are using indexed color mode.
You do not EVER want to use indexed color when you are
working with object graphics.

Cheers,

David



--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Alpha blending with object graphics - different color palettes do not work [message #75952 is a reply to message #75784] Wed, 04 May 2011 22:50 Go to previous message
LNpellen is currently offline  LNpellen
Messages: 37
Registered: November 2009
Member
For now I just want to apply the same alpha-blending on all pixels so
the indexed image together with the ALPHA_CHANNEL worked out fine for
me. Thank you!
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Problem using ReadS to read a long string
Next Topic: Re: summation of bands

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 11:39:50 PDT 2025

Total time taken to generate the page: 0.00616 seconds