pktools
2.6.7
Processing Kernel for geospatial data

Filter input.tif with morphological dilation filter. Use a circular kernel (instead of rectangular) of size 3x3.
Similar to previous example, but consider only values of 255 for filtering operation. Typical usage: dilate cloud values in input image that are flagged as 255
Calculate the median value for each pixel, calculated on a moving window of width 3 (dz 3) over all input bands. The output raster dataset will contain as many bands as the input raster dataset.
Calculate the standard deviation for each pixel, calculated on all input bands. The output raster dataset will contain a single band only, no moving window is used (dz 1).
"Smooth" (interpolate) nodata in spectral/temporal domain (dz 1), using a linear interpolation. The following interpolation types are supported: akima (default), linear, polynomial, cspline, cspline_periodic, akima_periodic (please check gsl page for more information on the interpolation types).
The following two examples show how to use pkfilter for spectral filtering a high dimensional input (hyperspectral image) to a lower dimensional output (multispectral image). Notice that the input wavelenghts must be provided as win value1 win value2 win value3 ... To save typing, we assume the input wavelengths are listed in a text file wavelengths.txt (single column ASCII file with all wavelenghts listed in nanometer).
In the first example, the hyperspectral image is filtered with a spectral response function. For each spectral response function provided, a separate output band is created. The spectral response function(s) must be listed in two column ASCII file(s) with the wavelengths and response listed in the first and second column respectively. The response functions can but must not be normalized (this is taken care of by the filter utility).
In this example, the input is a hyperspectral image with N>>1 spectral wavelengths (bands). The output is a multispectral image with 3 bands, where a spectral response function is provided for each output band.
The next example is similar to the previous. Instead of providing a spectral response function for each output band, you can also provide the center wavelengths and full width half max values. Here, a three band (red, green, blue) output image is produced.
The following example reconstructs a timeseries data set based on the Savitzky–Golay filter, as suggested by J. Chen 2004.
Input is a multiband (Byte) raster dataset containing a noisy time series, e.g., a normalized difference vegetation index (NDVI) with cloud contaminated (low) NDVI values. Output is the reconstructed timeseries data set, which approaches the upper NDVI enveloppe. Please refer to J. Chen 2004 for more details.
Create a longterm change trend fitting (lta.tif) using the SavitzkyGolay filter. Choose the number of lefward (past) and rightward (future) data points (e.g., 7). The order of smoothing polynomial in the SavitzkyGolay filter is set to 2.
Decrease the number of lefward (past) and rightward (future) data points to 4. The order of smoothing polynomial in the SavitzkyGolay filter is set to 6. Valid data are from 0 to 250 (nodata is set to 250).
Output savgolay<n>.tif is the reconstructed timeseries data set.