Board index » delphi » Shade relief maps. Where to start?

Shade relief maps. Where to start?


2006-12-15 04:52:12 PM
delphi268
Hello,
My application creates colored maps and I wish to apply a shaded relief
filter but I don't know where to start. Any good recommendations will be
much appreciated.
Regards
 
 

Re:Shade relief maps. Where to start?

Peter S. writes:
Quote
Hello,

My application creates colored maps and I wish to apply a shaded relief
filter but I don't know where to start. Any good recommendations will be
much appreciated.

Regards


GLScene at glscene.sourceforge.net/wikka/HomePage?
--
Willem van Deursen, The Netherlands
XXXX@XXXXX.COM
replace _nospam@nospam_ for @ to get a valid email address
www.carthago.nl
 

Re:Shade relief maps. Where to start?

"Peter S." <XXXX@XXXXX.COM>writes
Quote
My application creates colored maps and I wish to apply a shaded relief
filter but I don't know where to start. Any good recommendations will be
much appreciated.
If the pixel to the left of the current pixel is lower in 'elevation',
lighten the pixel color.
if the pixel to the left of the current pixel is higher in 'elevation',
darken it.
You can obviously get much fancier, but there's a start.
 

Re:Shade relief maps. Where to start?

Hello,
Thank you for the information. I found some code but it is written in C++
and although the I understand the idea I cnnot understand the color
"handling" (regarding the pixels).
Can you please post some code on how to lighten or darken a color? My bitmap
is a 24bit bitmap and I found some code on how to get the R,G,B values of a
single pixel.
Regards
?"GrandmasterB" <XXXX@XXXXX.COM>έγραψε στ?μήνυμα
Quote
"Peter S." <XXXX@XXXXX.COM>writes
news:XXXX@XXXXX.COM...
>My application creates colored maps and I wish to apply a shaded relief
>filter but I don't know where to start. Any good recommendations will be
>much appreciated.

If the pixel to the left of the current pixel is lower in 'elevation',
lighten the pixel color.
if the pixel to the left of the current pixel is higher in 'elevation',
darken it.

You can obviously get much fancier, but there's a start.



 

Re:Shade relief maps. Where to start?

"Peter S." <XXXX@XXXXX.COM>writes
Quote
Can you please post some code on how to lighten or darken a color? My
bitmap
is a 24bit bitmap and I found some code on how to get the R,G,B values of
a
single pixel.
To lighten or darken, add/subtract a fixed value to each color component.
It may seem counter intuitive to just add to each component like that, but
its pretty effective.
For ex (pseudo code - this wont compile):
p := scanline[x];
r := GetRValue( p);
g := GetGValue( p);
b := GetBValue( p);
endcolor := RGB( r + 40, g + 40, b + 40);
You'd want to add in checks to make sure the color components are>= 0 and
<= 255.
There's other ways of doing the shading, but this is quick and decent enough
for a lot of 2d applications.
 

Re:Shade relief maps. Where to start?

I will give it a try. Thank you very much
?"GrandmasterB" <XXXX@XXXXX.COM>έγραψε στ?μήνυμα
Quote
"Peter S." <XXXX@XXXXX.COM>writes
>Can you please post some code on how to lighten or darken a color? My
>bitmap
>is a 24bit bitmap and I found some code on how to get the R,G,B values
of
>a
>single pixel.

To lighten or darken, add/subtract a fixed value to each color component.
It may seem counter intuitive to just add to each component like that, but
its pretty effective.

For ex (pseudo code - this wont compile):

p := scanline[x];

r := GetRValue( p);
g := GetGValue( p);
b := GetBValue( p);

endcolor := RGB( r + 40, g + 40, b + 40);

You'd want to add in checks to make sure the color components are>= 0 and
<= 255.

There's other ways of doing the shading, but this is quick and decent
enough
for a lot of 2d applications.