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

Home » Public Forums » archive » Re: Map transparent image
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: Map transparent image [message #35679] Tue, 01 July 2003 12:50 Go to next message
Haje Korth is currently offline  Haje Korth
Messages: 651
Registered: May 1997
Senior Member
Step two was what I needed to figure out: Alpha blending was the answer.

Thanks,
Haje


"Andy Loughe ( remove OMITs )" <Andrew.LougheOMIT@noaaOMIT.govOMIT> wrote in
message news:3F019EC8.2030608@noaaOMIT.govOMIT...
> Can this be accomplished by...
>
> (1) preparing the image to be created, like via map_set.
> (2) using polyfill or another technique to draw the (lightly colored)
mask.
> (3) "overplotting" with the data values included, then adding
> continents, grids, etc.
>
> ... or maybe your needs are more complex than this.
>
>
> Haje Korth wrote:
>> Good morning everyone,
>> I am trying to overlay a grey-shaded mask over an image to indicate
areas
>> where sample data are less reliable. However, I want the grey shaded
area to
>> be transparent so that I can still see the underlying data points. I do
not
>> want to use 'contour' since the results look rather confusing; too many
>> patches. As far as I can see, the IDL map_image command does not provide
>> such settings. Does anyone know, how the mask can be worked into the
image
>> prior to display? What is the math that one would apply?
>>
>> Thanks for helping,
>> Haje
>>
>>
>
>
> --
> Andrew Loughe =====================================================
> NOAA/OAR/FSL/AD R/FS5 | email: Andrew.Loughe@noaa.gov
> 325 Broadway | wwweb: www-ad.fsl.noaa.gov/users/loughe
> Boulder, CO 80305-3328 | phone: 303-497-6211 fax: 303-497-6301
>
Re: Map transparent image [message #35680 is a reply to message #35679] Tue, 01 July 2003 12:49 Go to previous messageGo to next message
Haje Korth is currently offline  Haje Korth
Messages: 651
Registered: May 1997
Senior Member
Michael,
this is a neat formula and I will print it for safe-keeping. I am fiddling
with the object graphics alpha blending and it works nicely. I knew this
could be reduced to one line of code, I just couldn't figure it out!

Thanks,
Haje


"Michael A. Miller" <mmiller3@iupui.edu> wrote in message
news:87vfumnjbh.fsf@lumen.indyrad.iupui.edu...
>>>> >> "Haje" == Haje Korth <haje.korth@jhuapl.edu> writes:
>
>> I am trying to overlay a grey-shaded mask over an image to
>> indicate areas where sample data are less
>> reliable. However, I want the grey shaded area to be
>> transparent so that I can still see the underlying data
>> points.
> ...
>> Does anyone know, how the mask can be worked into the image
>> prior to display? What is the math that one would apply?
>
> One method that you might like is alpha blending. If you have
> two images with two different colors (from two color maps say),
> calculate a new color map like
>
> RGB = BYTE( alpha * FLOAT(baseRGB) + (1.0 - alpha) *
FLOAT(overlayRGB) )
>
> where the *RGB are RGB 3-tuples. You can do this by hand, so to
> speak, in your own code if you are using direct graphics, or you
> can use the alpha blending that is built into object graphics.
>
> Mike
>
> --
> Michael A. Miller mmiller3@iupui.edu
> Imaging Sciences, Department of Radiology, IU School of Medicine
Re: Map transparent image [message #35681 is a reply to message #35680] Tue, 01 July 2003 12:43 Go to previous messageGo to next message
Haje Korth is currently offline  Haje Korth
Messages: 651
Registered: May 1997
Senior Member
I think I should shut up now, otherwise you will find out what a lousy
programmer I am... :-)

Haje


"David Fanning" <david@dfanning.com> wrote in message
news:MPG.196b7cfc7a50056198969a@news.frii.com...
> Haje Korth writes:
>
>> I was already wondering whether there are map routines in object
graphics? I
>> am doing it quick and dirty: map into Z-buffer, tvrd(), then use the
>> resulting image for the object. Not pretty, but this way I can overlay a
>> clean mask that is NOT pixelated!
>
> Ah, right. The ol' smoke and mirrors approach!
> It's probably a good idea, given the available
> alternatives. :-)
>
> Cheers,
>
> David
>
> --
> David W. Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Phone: 970-221-0438, E-mail: david@dfanning.com
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
> Toll-Free IDL Book Orders: 1-888-461-0155
Re: Map transparent image [message #35682 is a reply to message #35681] Tue, 01 July 2003 12:51 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Michael A. Miller writes:

> One method that you might like is alpha blending. If you have
> two images with two different colors (from two color maps say),
> calculate a new color map like
>
> RGB = BYTE( alpha * FLOAT(baseRGB) + (1.0 - alpha) * FLOAT(overlayRGB) )
>
> where the *RGB are RGB 3-tuples. You can do this by hand, so to
> speak, in your own code if you are using direct graphics, or you
> can use the alpha blending that is built into object graphics.

Oh, yes, that looks nice. Here is a little example
if you happen to have some of my programs hanging around
and a 24-bit display.

Window
LoadCT, 5
TVImage, LoadData(7)
a = TVRead()
LoadCT, 0
TVImage, (LoadData(5) GT 40) * 255B
b = TVRead()
alpha = 0.5
rgb = BYTE( alpha * FLOAT(a) + (1.0 - alpha) * FLOAT(b) )
TVImage, rgb

*Very* slick!

Cheers,

David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: Map transparent image [message #35683 is a reply to message #35681] Tue, 01 July 2003 12:22 Go to previous message
mmiller3 is currently offline  mmiller3
Messages: 81
Registered: January 2002
Member
>>>> > "Haje" == Haje Korth <haje.korth@jhuapl.edu> writes:

> I am trying to overlay a grey-shaded mask over an image to
> indicate areas where sample data are less
> reliable. However, I want the grey shaded area to be
> transparent so that I can still see the underlying data
> points.
...
> Does anyone know, how the mask can be worked into the image
> prior to display? What is the math that one would apply?

One method that you might like is alpha blending. If you have
two images with two different colors (from two color maps say),
calculate a new color map like

RGB = BYTE( alpha * FLOAT(baseRGB) + (1.0 - alpha) * FLOAT(overlayRGB) )

where the *RGB are RGB 3-tuples. You can do this by hand, so to
speak, in your own code if you are using direct graphics, or you
can use the alpha blending that is built into object graphics.

Mike

--
Michael A. Miller mmiller3@iupui.edu
Imaging Sciences, Department of Radiology, IU School of Medicine
Re: Map transparent image [message #35684 is a reply to message #35683] Tue, 01 July 2003 07:46 Go to previous message
Andy Loughe ( remove  is currently offline  Andy Loughe ( remove
Messages: 3
Registered: July 2003
Junior Member
Can this be accomplished by...

(1) preparing the image to be created, like via map_set.
(2) using polyfill or another technique to draw the (lightly colored) mask.
(3) "overplotting" with the data values included, then adding
continents, grids, etc.

... or maybe your needs are more complex than this.


Haje Korth wrote:
> Good morning everyone,
> I am trying to overlay a grey-shaded mask over an image to indicate areas
> where sample data are less reliable. However, I want the grey shaded area to
> be transparent so that I can still see the underlying data points. I do not
> want to use 'contour' since the results look rather confusing; too many
> patches. As far as I can see, the IDL map_image command does not provide
> such settings. Does anyone know, how the mask can be worked into the image
> prior to display? What is the math that one would apply?
>
> Thanks for helping,
> Haje
>
>


--
Andrew Loughe =====================================================
NOAA/OAR/FSL/AD R/FS5 | email: Andrew.Loughe@noaa.gov
325 Broadway | wwweb: www-ad.fsl.noaa.gov/users/loughe
Boulder, CO 80305-3328 | phone: 303-497-6211 fax: 303-497-6301
Re: Map transparent image [message #35687 is a reply to message #35684] Tue, 01 July 2003 11:12 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Haje Korth writes:

> I was already wondering whether there are map routines in object graphics? I
> am doing it quick and dirty: map into Z-buffer, tvrd(), then use the
> resulting image for the object. Not pretty, but this way I can overlay a
> clean mask that is NOT pixelated!

Ah, right. The ol' smoke and mirrors approach!
It's probably a good idea, given the available
alternatives. :-)

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: Map transparent image [message #35688 is a reply to message #35684] Tue, 01 July 2003 10:45 Go to previous message
Haje Korth is currently offline  Haje Korth
Messages: 651
Registered: May 1997
Senior Member
I was already wondering whether there are map routines in object graphics? I
am doing it quick and dirty: map into Z-buffer, tvrd(), then use the
resulting image for the object. Not pretty, but this way I can overlay a
clean mask that is NOT pixelated!

Haje


"David Fanning" <david@dfanning.com> wrote in message
news:MPG.196b561268c0dc2e989699@news.frii.com...
> Haje Korth writes:
>
>> I have found that article an hour ago searching the net in desperation.
The
>> pixelation stuff looks extremely ugly. However, I like the object
graphicsw
>> stuff and now I have an excuse to learn object graphics! I knew sooner
or
>> later I would get the opportunity. it is actually not that hard. after a
few
>> tries i even got it to work with ION. Thanks for the hint though. I
should
>> have never posted without consulting your site first... :-)
>
> Well, you were talking about "map_image", which
> *definitely* implies direct graphics. If you
> are hoping to use object graphics with map projections
> I'm afraid you have *way* more work cut out for yourself
> than just learning about object graphics. :-)
>
> Cheers,
>
> David
>
> --
> David W. Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Phone: 970-221-0438, E-mail: david@dfanning.com
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
> Toll-Free IDL Book Orders: 1-888-461-0155
Re: Map transparent image [message #35692 is a reply to message #35684] Tue, 01 July 2003 08:26 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Haje Korth writes:

> I have found that article an hour ago searching the net in desperation. The
> pixelation stuff looks extremely ugly. However, I like the object graphicsw
> stuff and now I have an excuse to learn object graphics! I knew sooner or
> later I would get the opportunity. it is actually not that hard. after a few
> tries i even got it to work with ION. Thanks for the hint though. I should
> have never posted without consulting your site first... :-)

Well, you were talking about "map_image", which
*definitely* implies direct graphics. If you
are hoping to use object graphics with map projections
I'm afraid you have *way* more work cut out for yourself
than just learning about object graphics. :-)

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: Map transparent image [message #35694 is a reply to message #35684] Tue, 01 July 2003 08:04 Go to previous message
Haje Korth is currently offline  Haje Korth
Messages: 651
Registered: May 1997
Senior Member
I have found that article an hour ago searching the net in desperation. The
pixelation stuff looks extremely ugly. However, I like the object graphicsw
stuff and now I have an excuse to learn object graphics! I knew sooner or
later I would get the opportunity. it is actually not that hard. after a few
tries i even got it to work with ION. Thanks for the hint though. I should
have never posted without consulting your site first... :-)

Haje


"David Fanning" <david@dfanning.com> wrote in message
news:MPG.196b397bada48ac5989696@news.frii.com...
> Haje Korth writes:
>
>> I am trying to overlay a grey-shaded mask over an image to indicate
areas
>> where sample data are less reliable. However, I want the grey shaded
area to
>> be transparent so that I can still see the underlying data points. I do
not
>> want to use 'contour' since the results look rather confusing; too many
>> patches. As far as I can see, the IDL map_image command does not provide
>> such settings. Does anyone know, how the mask can be worked into the
image
>> prior to display? What is the math that one would apply?
>
> There is a pixelation technique described in this article
> that I think would work:
>
> http://www.dfanning.com/color_tips/color_overlay.html
>
> Create two images: one normal and the other normal with
> the gray mask opaquely on top. Then pixelate the two.
> You should end up with an image in which the colors show
> through the gray, where the gray is present and looks normal
> otherwise.
>
> Cheers,
>
> David
>
> P.S. I haven't tried this, but sometimes you just
> feel extraordinarily confident something is going to
> work. :-)
>
> --
> David W. Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Phone: 970-221-0438, E-mail: david@dfanning.com
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
> Toll-Free IDL Book Orders: 1-888-461-0155
Re: Map transparent image [message #35699 is a reply to message #35684] Tue, 01 July 2003 06:24 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Haje Korth writes:

> I am trying to overlay a grey-shaded mask over an image to indicate areas
> where sample data are less reliable. However, I want the grey shaded area to
> be transparent so that I can still see the underlying data points. I do not
> want to use 'contour' since the results look rather confusing; too many
> patches. As far as I can see, the IDL map_image command does not provide
> such settings. Does anyone know, how the mask can be worked into the image
> prior to display? What is the math that one would apply?

There is a pixelation technique described in this article
that I think would work:

http://www.dfanning.com/color_tips/color_overlay.html

Create two images: one normal and the other normal with
the gray mask opaquely on top. Then pixelate the two.
You should end up with an image in which the colors show
through the gray, where the gray is present and looks normal
otherwise.

Cheers,

David

P.S. I haven't tried this, but sometimes you just
feel extraordinarily confident something is going to
work. :-)

--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: IDL from crontab going defunct?
Next Topic: cwavefor

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

Current Time: Wed Oct 08 13:47:08 PDT 2025

Total time taken to generate the page: 0.00639 seconds