Reference

pkfilter(1)

program to filter raster images

NAME

pkfilter - program to filter raster images

SYNOPSIS

FCpkfilterF[0] FC-iF[0] input FC-oF[0] output [FC-fF[0] filter | FC-srfF[0] file [FC-srfF[0] file]... | FC-fwhmF[0] value [FC-fwhmF[0] value]... ] [options] [advanced options]

DESCRIPTION

pkfilter implements spatial and spectral filtering for raster data. In the spatial domain (X, Y), the filter typically involves a rectangular convolution kernel (moving window). To avoid image shifting, the size of the window should be odd (3, 5, 7, ...). You can set the window sizes in X and Y directions separately with the options FC-dxF[0] and FC-dyF[0]. A circular kernel (disc) is applied if option FC-circF[0] is set. An overview of the supported filters (option FC-fF[0]|FC--filterF[0]) is given below. You can create customized filters by defining your own filter taps (multiplicative elements of the filter kernel) via an ascii file (option FC-tapF[0]). In the spectral/temporal domain (Z) you can filter multi-band raster inputs. The kernel filter size can be set with the option FC-dzF[0] (use odd values only).

FILTERS IN SPATIAL (DX, DY) AND SPECTRAL/TEMPORAL (DZ) DOMAIN

The number of output bands equals number of input bands

FilterDescription
dilatemorphological dilation
erodemorphological erosion
closemorpholigical closing (dilate+erode)
openmorpholigical opening (erode+dilate)
smoothnodata valuessmooth nodata values (set FC--nodataF[0] option!)

Example: "Smooth" (interpolate) nodata in spectral/temporal domain (FC-dzF[0] 1), using a linear interpolation

FC
pkfilter -i input.tif -o smoothed.tif -dz 1 -f smoothnodata -interp linear
          F[0]

Example: Filter input.tif in spatial domain with morphological dilation filter with kernel size 3x3.

FC
pkfilter -i input.tif -o dilated.tif -dx 3 -dy 3 -f dilate
          F[0]

In case of moving window, the number of output bands equals number of input bands. In case dz=1, the single output band is calculated as the result of the statistical function applied to all bands.

FilterDescription
nvalidreport number of valid (not nodata) values in window
medianperform a median filter in spatial (dx, dy) or spectral/temporal (dz) domain
varcalculate variance in window
mincalculate minimum in window
maxcalculate maximum in window
sumcalculate sum in window
meancalculate mean in window
stdevcalculate standard deviation in window
savgolaySavitzky-Golay filter (check examples page!)
percentilecalculate percentile value in window
proportioncalculate proportion in window

Example: Median filter in spatial domain

FC
pkfilter -i input.tif -o median.tif -dx 3 -dy 3 -f median
          F[0]

Example: Calculate statistical variance in spectral/temporal domain (single output band)

FC
pkfilter -i input.tif -o var.tif -dz 1 -f var
          F[0]

WAVELET FILTERS

The number of output bands equals number of input bands

FilterDescription
dwtdiscrete wavelet transform
dwtidiscrete inverse wavelet transform
dwt_cutdiscrete wavelet + inverse transform, using threshold option to cut percentile of coefficients

Example: Calculate discrete wavelet in spatial domain

FC
pkfilter -i lena.tif -o lena_dwt.tif -f dwt
          F[0]

Example: Calculate discrete wavelet in spectral/temporal domain

FC
pkfilter -i timeseries.tif -o dwt.tif -f dwt -dz 1
          F[0]

The number of output bands equals number of input bands

FilterDescription
dwt_cut_fromdiscrete wavelet + inverse transform, setting all high frequence coefficients to zero (scale >= threshold)

Example: Calculate low frequency time series based on discrete wavelet + inverse transform in spectral/temporal domain, retaining only coefficients until scale 3.

FC
pkfilter -i timeseries.tif -o lowfrequency.tif -f dwt_cut_from -dz 1 -t 4
          F[0]

FILTERS IN SPATIAL DOMAIN ONLY (DX, DY > 1 AND ODD).

The number of output bands equals number of input bands.

FilterDescription
mrfMarkov random field
isminpixel is minimum?
ismaxpixel is maximum?
shiftperform a pixel shift in spatial window
scramblescramble pixels in a spatial window
mode (majority voting)perform a majority voring (set FC--classF[0] option)
sobelxhorizontal edge detection
sobelyvertical edge detection
sobelxydiagonal edge detection (NE-SW)
sobelyxdiagonal edge detection (NW-SE)
countidcount digital numbers in window
orderrank pixels in order
densitycalculated the density
homogcentral pixel must be identical to all other pixels within window
heterogcentral pixel must be different than all other pixels within window
sauvolaSauvola's thresholding method

Example: Sobel edge detection in horizontal direction

FC
pkfilter -i lena.tif -o sobelx.tif -f solbelx -dx 5 -dy 5
        F[0]

OPTIONS

FC-iF[0] filename, FC--inputF[0] filename

input image

FC-oF[0] filename, FC--outputF[0] filename

output classification image

FC-fF[0] filter, FC--filterF[0] filter

filter function (nvalid, median, var, min, max, sum, mean, dilate, erode, close, open, homog (central pixel must be identical to all other pixels within window), heterog (central pixel must be different than all other pixels within window), sobelx (horizontal edge detection), sobely (vertical edge detection), sobelxy (diagonal edge detection NE-SW),sobelyx (diagonal edge detection NW-SE), density, countid, mode (majority voting, only for classes), smoothnodata (smooth nodata values only) values, ismin, ismax, order (rank pixels in order), stdev, mrf, dwt, dwti, dwt_cut, dwt_cut_from, scramble, shift, savgolay, percentile, proportion)

FC-dxF[0] value, FC--dxF[0] value

filter kernel size in x, use odd values only

FC-dyF[0] value, FC--dyF[0] value

filter kernel size in y, use odd values only

FC-dzF[0] value, FC--dzF[0] value

filter kernel size in z (band or spectral dimension), must be odd (example: 3). Set dz>0 if 1-D filter must be used in band domain

FC-nodataF[0] value, FC--nodataF[0] value

nodata value(s) (used for smoothnodata filter)

FC-vF[0] level, FC--verboseF[0] level

verbose mode if > 0

Advanced options

FC-circF[0], FC--circularF[0]

circular disc kernel for dilation and erosion

FC-rF[0] method, FC--resampling-methodF[0] method

Resampling method for shifting operation (near: nearest neighbour, bilinear: bi-linear interpolation).

FC-coF[0] option, FC--coF[0] option

Creation option for output file. Multiple options can be specified.

FC-wtF[0] type, FC--waveletF[0] type

wavelet type: daubechies,daubechies_centered, haar, haar_centered, bspline, bspline_centered

FC-wfF[0] family, FC--wfF[0] family

wavelet family (vanishing moment, see also http://www.gnu.org/software/gsl/manual/html_node/DWT-Initialization.html)

FC-classF[0] value, FC--classF[0] value

class value(s) to use for density, erosion, dilation, openening and closing, thresholding

FC-tF[0] threshold, FC--thresholdF[0] threshold

threshold value(s) to use for threshold filter (one for each class), or threshold to cut for dwt_cut (use 0 to keep all) or dwt_cut_from, or sigma for shift

FC-tapF[0] filename, FC--tapF[0] filename

text file containing taps used for spatial filtering (from ul to lr). Use dimX and dimY to specify tap dimensions in x and y. Leave empty for not using taps

FC-tapzF[0] value, FC--tapzF[0] value

taps used for spectral filtering

FC-padF[0] method, FC--padF[0] method

Padding method for filtering (how to handle edge effects). Choose between: symmetric, replicate, circular, constant (pad with 0).

FC-fwhmF[0] value, FC--fwhmF[0] value

list of full width half to apply spectral filtering (FC-fwhmF[0] band1 FC-fwhmF[0] band2 ...)

FC-srfF[0] filename, FC--srfF[0] filename

list of ASCII files containing spectral response functions (two columns: wavelength response)

FC-winF[0] col, FC--wavelengthInF[0] col

column number of input ASCII file containing wavelengths

FC-woutF[0] value, FC--wavelengthOutF[0] value

list of wavelengths in output spectrum (FC-woutF[0] band1 FC-woutF[0] band2 ...)

FC-downF[0] value, FC--downF[0] value

down sampling factor. Use value 1 for no downsampling). Use value n>1 for downsampling (aggregation)

FC-betaF[0] filename, FC--betaF[0] filename

ASCII file with beta for each class transition in Markov Random Field

FC-epsF[0] value, FC--epsF[0] value

error marging for linear feature

FC-l1F[0], FC--l1F[0]

obtain longest object length for linear feature

FC-a1F[0], FC--a1F[0]

obtain angle found for longest object length for linear feature

FC-a2F[0], FC--a2F[0]

obtain angle found for shortest object length for linear feature

FC-interpF[0] type, FC--interpF[0] type

type of interpolation for spectral filtering (see http://www.gnu.org/software/gsl/manual/html_node/Interpolation-Types.html)

FC-otF[0] type, FC--otypeF[0] type

Data type for output image ({Byte / Int16 / UInt16 / UInt32 / Int32 / Float32 / Float64 / CInt16 / CInt32 / CFloat32 / CFloat64}). Empty string: inherit type from input image

FC-ofF[0] GDALformat, FC--oformatF[0] GDALformat

Output image format (see also gdal_translate(1)).

FC-ctF[0] filename, FC--ctF[0] filename

color table (file with 5 columns: id R G B ALFA (0: transparent, 255: solid)). Use none to omit color table

EXAMPLE

Filtering in spatial domain

Filter input.tif with morphological dilation filter. Use a circular kernel (instead of rectangular) of size 3x3.

FC
pkfilter -i input.tif -o filter.tif -dx 3 -dy 3 -f dilate -circ
      F[0]

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

FC
pkfilter -i input.tif -o filter.tif -dx 3 -dy 3 -class 255 -f dilate -circ
      F[0]

Filtering in spectral/temporal domain

Calculate the median value for each pixel, calculated on a moving window of width 3 (FC-dzF[0] 3) over all input bands. The output raster dataset will contain as many bands as the input raster dataset.

FC
pkfilter -i input.tif -o filter_stdev.tif -dz 3 -f median
      F[0]

No moving window (FC-dzF[0] 1). Calculate the standard deviation for each pixel, calculated on all input bands. The output raster dataset will contain a single band only.

FC
pkfilter -i input.tif -o filter_stdev.tif -dz 1 -f stdev
      F[0]

"Smooth" (interpolate) nodata in spectral/temporal domain (FC-dzF[0] 1), using a linear interpolation. The following interpolation types are supported: akima (default), linear, polynomial, cspline, cspline_periodic, akima_periodic (please check gsl ⟨http://www.gnu.org/software/gsl/manual/html_node/Interpolation-Types.html⟩ page for more information on the interpolation types).

FC
pkfilter -i input.tif -o input_smoothed.tif -dz 1 -f smoothnodata -interp linear
      F[0]

History