4.33333

4.3 | 3 ratings Rate this file 26 downloads (last 30 days) File Size: 3.42 KB File ID: #14863

Hillshade

by Felix Hebeler

 

03 May 2007 (Updated 07 May 2007)

No BSD License  

calculates a hillshade for a DEM (matrix)

Download Now | Watch this File

File Information
Description

Function to calculate hillshade for a digital elevation model. Derives slope and aspect in radias to calculate shading value between 0 and 255 using a given lighting angle and altitude.

Altitude (angle above ground) and angle (direction/aspect) of lightsource can be given via args.

Derived using ESRIs hillshade algorithm, but uses simple GRADIENT function instead of Horns algorithm for slope calculation - factor 30 more efficient & no need for IP TB. (Thanks to Andrew Stevens)

Pls leave you feedback/rate.

MATLAB release MATLAB 7.3 (R2006b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (4)
03 May 2007 Andrew Stevens

Well done! Easy to use, good comments and produced a nice result for me. Thanks.

One question: could something like the "gradient" function be used instead of nlfilt. That way, users wouldn't need the IP toolbox to implement.

05 May 2007 Felix Hebeler

Implemented the GRADIENT function - thanks for the suggestions and code, its much faster now...

13 Mar 2008 Giuliano Langella

I find very useful this function. I wonder if you have implemented also other hydrological/geomorphological functions in MatLab, such as PLAN/PROFILE curvatures, etc.

I suggest the following call to hillshade function in case of R reference matrix:
>> h = hillshade(Z, (R(3,1)+R(2,1)):R(2,1):(R(3,1)+size(Z,2)*R(2,1)), R(3,2)+R(1,2):R(1,2):(R(3,2)+size(Z,2)*R(1,2)));

with
R = [0,-cellsize; cellsize,0; up_left_pixel_X,up_left_pixel_Y];

Thanks.

22 Aug 2008 Evana Rosylee

hi,

i was refering to your code on finding the slope and aspect up til the gradient part.it really is good and it helps me alot.now,i have a DEM image of 1400x1400 in bitmap format,grayscale(0-255).I need to pick two points on the pixel in order for me to calculate the slope and aspect.my problem now is,how can i automatically run for every pixel in the image?i know i have to use the loop function but i don't know how.any suggestion is welcome..thank u~

Please login to add a comment or rating.
Updates
04 May 2007

Update to set hillshade 0 for values <0.
Include example.

07 May 2007

Changed calculation to use GRADIENT function instead of nlfilter. Increases calculation speed by factor 30 and does not need ImageProcessing TB.

07 May 2007

fixed small bug in the options parsing, clearified help.

Tag Activity for this File
Tag Applied By Date/Time
hillshade Felix Hebeler 22 Oct 2008 09:11:28
dem Felix Hebeler 22 Oct 2008 09:11:28
shading Felix Hebeler 22 Oct 2008 09:11:28
aspect Felix Hebeler 22 Oct 2008 09:11:28
slope Felix Hebeler 22 Oct 2008 09:11:28

Contact us at files@mathworks.com