Changes to imageschs

Posted on

imageschs is one of the functions that I most frequently use. Admittedly, it has a somewhat non-intuitive name. Yet, the function’s name is simply the concatenation of imagesc, a MATLAB built-in function to display an image with scaled colors, and hs, which abbreviates hillshading. In combination, imageschs displays an image (or GRIDobj) with a shading based on an underlying digital elevation model (DEM).

The syntax of imageschs is quite simple, but there are a number of parameter name/value pairs that you may use to control some additional behavior of the function. The parameter name/value pairs are documented in the help section of the function that can be accessed via

help imageschs

Here I briefly outline some new functionality that I added lately.

1. Median filtering

Smoothing the hillshade has proven successful to reduce the effect of small geographic features on shading, instead emphasizing the larger scale geographic patterns. Many software packages use a median filter and imageschs now does so as well:

ax(1) = subplot(1,2,1);
imageschs(DEM,[],'colorbar',false)

ax(2) = subplot(1,2,2);
imageschs(DEM,[],'medfilt',true,'colorbar',false)

2. Percent clipping

By default, imageschs linearly scales the color range between the minimum and maximum value of the coloring image or GRIDobj. Sometimes, this range may be strongly affected by just a few extreme values. This is particularly true for curvature, that usually contains values close to zero, but often has few values which are very high or low. The linear scaling inbetween these values entails that all patterns characterized by smaller variations become invisible. imageschs can now remove those values using percentage clipping. That means that the scaling applies only to the value range between the X%’s and 100-X%’s percentile of the data.

C = curvature(DEM);
imageschs(DEM,C,'percentclip',2)

3. Make the hillshade permanent

Have you ever been annoyed that imageschs takes a while if you have to call it repeatedly although you always use the same DEM? Now you can use the option ‘usepermanent’ to reduce waiting time. If this option is set to true, imageschs will store the hillshade as a persistent variable and will make it available if the function is called next time. Of course, this will only work out if the DEM (actually, its hillshade) and the coloring matrix or GRIDobj have the same dimensions. And of coarse, beware that any changes that you make to the DEM in the meantime remain disregarded by imageschs.

DEM = resample(DEM,5);
DEM = crop(DEM);

G = filter(gradient8(DEM),'mean',11);
tic;imageschs(DEM,[],'usepermanent',true); toc
Elapsed time is 3.599666 seconds.
tic;imageschs(DEM,G,'usepermanent',true); toc
Elapsed time is 0.717102 seconds.

Ok, that’s it about recent changes to imageschs. Please leave a comment or report bugs!

Advertisements

2 thoughts on “Changes to imageschs

    Ankit Pramanik said:
    June 9, 2017 at 5:24 pm

    Hi,
    It’s a nice tool. When I am changing my caxis like caxis ([xi, yi]), only colorbar is changing, the color of the figure is not changing. Could you please help? Or am I missing something?

    Thank you.

    Regards,
    Ankit

    wschwanghart responded:
    July 10, 2017 at 11:22 am

    Hi Ankit, thanks for your mail and apologies for my late response. The color range of an image created with imageschs cannot be changed afterwards since it is stored as an RGB image. However, the function has a parameter name/value pair that allows setting caxis.
    Cheers, Wolfgang

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s