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.
Felix Hebeler (2021). Hillshade (https://www.mathworks.com/matlabcentral/fileexchange/14863-hillshade), MATLAB Central File Exchange. Retrieved .
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~
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)));
R = [0,-cellsize; cellsize,0; up_left_pixel_X,up_left_pixel_Y];
Implemented the GRADIENT function - thanks for the suggestions and code, its much faster now...
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.
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!