|
|
Re: How to plot shaded relief image [message #57995 is a reply to message #57830] |
Thu, 10 January 2008 03:56  |
JMB
Messages: 13 Registered: January 2008
|
Junior Member |
|
|
Very simple example in easy case:
South illumination, only sun angle (i) can be set:
;*********************************************************** *****
dem=read_tiff('dem.tif')
dims=size(dem,/dimensions)
; Edit a 3x3 gradient operator (vertical)
gradv=[[1,1,1],[0,0,0],[-1,-1,-1]]
; convolution of the dem with the 3x3 matrix
gradient=convol(float(dem),float(gradv))
; Sun angle respect to zenith (0 = vertical light, 90 = horizontal
light)
i=60
cosi=cos(i*!pi/180.)
sini=sin(i*!pi/180.)
; resx = Dem horizontal resolution in meter (needed for normalization)
resx=90 ; SRTM at 90 meter resolution in this test example
resxmat=make_array(dims[0],dims[1],value=2*resx) ; matrix used for the
scalar product
; Computation of the shading matrix:
; Scalar product of incident vector and normal gives cosinus angle
Norm=1/(sqrt(gradient^2+(2*resx)^2)) ; Normalization
costeta=Norm*(cosi*resxmat-sini*gradient)>0
window,0,xsize=dims[0],ysize=dims[1]
tvscl,dem
window,2,xsize=dims[0],ysize=dims[1]
tvscl,costeta
end
;*********************************************************** *****
Cheers,
Jérôme
|
|
|
Re: How to plot shaded relief image [message #58009 is a reply to message #57830] |
Wed, 09 January 2008 12:28  |
JMB
Messages: 13 Registered: January 2008
|
Junior Member |
|
|
Hi all,
I have to correct my precedent post.
The "kind of shading matrix" I introduced before is NOT the shading
given by a source of light incident on the DEM,
It is a directional gradient of the DEM. High positive values
correspond to high slopes in uphill direction, low negative values
correspond to high slopes in downhill direction, zero values
correspond to flat areas. The 3x3 matrix operator defines the
direction of the gradient of interest.
I will try to give in a few days a better algorithm to compute shading
on a dem from an incident light defined by a 3D vector.
Cheers,
Jerome
|
|
|