Tag Archives: Filters

Image Filters in RSGISLib

There are a number of image filters available in RSGISLib, including texture filters. The interface is designed to make it easy to apply a number of filters, which form a filter bank, to an image. A base name for the output is provided and for each filter a different file ending is appended. For example to apply a mean and median filter to an image using the XML interface the following is used:

<rsgis:commands xmlns:rsgis="http://www.rsgislib.org/xml/">

    <rsgis:command algor="imagefilter" option="filter" 
        image="injune_p142_casi_sub_singleband.kea" 
        output="Filtered/injune_p142_casi_sub_singleband" 
        format="KEA"
        extension="kea" datatype="Float32" >
        <rsgis:filter size="3" type="Mean" fileending="mean" />
        <rsgis:filter size="3" type="Median" fileending="median" />
      </rsgis:command>

</rsgis:commands>

The above example will produce two files ‘Filtered/injune_p142_casi_sub_singleband_mean.kea’ and ‘Filtered/injune_p142_casi_sub_singleband_median.kea’.

The filters can also be accessed using the new Python interface, where each filter is provided as a ‘FilterParameters’ object.

inputImage = 'injune_p142_casi_sub_singleband.kea'
outputImageBase = 'Filtered/injune_p142_casi_sub_utm_single_band'
gdalFormat = 'KEA'
outExt = 'kea'
dataType = rsgislib.TYPE_32FLOAT
filters = []
filters.append(imagefilter.FilterParameters(filterType = 'Mean', 
    fileEnding = 'mean', size=3) )
filters.append(imagefilter.FilterParameters(filterType = 'Median', 
    fileEnding = 'median', size=3) )
imagefilter.applyfilters(inputImage, outputImageBase, filters, 
    gdalFormat, outExt, dataType)

The Leung-Malik (2001) filter bank is available through RSGISLib for extracting textural features from images and is accessible using the XML interface:

<rsgis:commands xmlns:rsgis="http://www.rsgislib.org/xml/">
    <rsgis:command algor="imagefilter" option="filter" filterbank="LM"
        image="injune_p142_casi_sub_singleband.kea" 
        output="LM/injune_p142_casi_sub_singleband_utm" 
        format="KEA" extension="kea" datatype="Float32" />
</rsgis:commands>

and Python bindings:

inputImage = 'injune_p142_casi_sub_singleband.kea'
outputImageBase = 'LM/injune_p142_casi_sub_utm_single_band'
gdalFormat = 'KEA'
outExt = 'kea'
dataType = rsgislib.TYPE_32FLOAT
imagefilter.LeungMalikFilterBank(inputImage, outputImageBase, 
    gdalFormat, outExt, dataType)

[1] Leung, T., Malik, J., 2001. Representing and recognizing the visual appearance of materials using three-dimensional textons. International Journal of Computer Vision 43 (1), 29-44.