Box filter: Difference between revisions

From Eigenvector Research Documentation Wiki
Jump to navigation Jump to search
imported>Neal
 
(6 intermediate revisions by 3 users not shown)
Line 8: Line 8:


===Description===
===Description===
Spatial statistical filter. To allow robust statistics the filter is based on a moving window (or box), and is slow compared to other filter methods.
BOX_FILTER is a spatial filter that filters and despises based on a moving window (or box). It tends to be slow compared to filter methods that can be vectorized.


====Inputs====
====Inputs====
* '''x''' = image data class 'double' or 'dataset'. If 'dataset' it must x.type=='image'. If 'double' it must be ''M''x''N''x''P'' (''P'' can = 1).
* '''x''' = MxNxP data class 'double' or 'dataset'. If 'dataset' it must x.type=='image' (see BUILDIMAGE). If 'double' it must be MxNxP (P can = 1 or N-way arrays).
* '''win''' = a 1 or 2 element vector of odd integers corresponding to the window width of the box filter. If scalar, (win) is set to win = [win win].
* '''win''' = a 1 or 2 element vector of odd integers corresponding to the window width of the box filter. If scalar, (win) is set to win = [win win].


====Outputs====
====Outputs====
* '''xf''' = Filtered image class 'dataset'.
* '''xf''' = Filtered image class 'dataset' or matrix (or N-way array) class 'double.'


===Options===
===Options===
Line 21: Line 21:
options =  a structure array with the following fields:
options =  a structure array with the following fields:


* '''algorithm''': [ {'mean'} | 'median' | 'max' | 'min' | 'meantrimmed' | 'mediantrimmed' ] governs filter method.
* '''algorithm''': [ {'mean'} | 'median' | 'max' | 'min' | 'despike' |  'meantrimmed' | 'mediantrimmed' ] governs filter method.
* '''ntrim''': when algorithm = 'meantrimmed' or 'mediantrimmed', (ntrim) is the input (n) to the functions MEANTRIMMED or MEDIANTRIMED {default = 2}.
* '''window movement''': [ {'bands'} | 'rectangle' ],  'bands' moves vertically then horizontally over a single window across the image or slab, and 'rectangle' moves a rectangular window across the image or slab.
despike parameters
* '''tol''': { [] } if empty then despike uses the std(median(x)) ''within each window'' to define the tolerance within the window.  If tol>0 scalar, then tol defines the tolerance ''for all the windows''. If tol<=0, then tol is estimated by the mean absolute deviation of madc(x.data(:)) and is the tolerance used for all the windows (see MADC).
* '''dsthreshold''': [ {2} ] Threshold used for the 'despike' algorithm. In contrast to replacing all values with the meidan (e.g., for options.algorithm = 'median'), 'despike' replaces only values outside |x-median(x)|>options.dsthreshold*options.tol with the median. (see options.tol)
* '''trbflag''': [ {'middle'} | 'bottom' | 'top' ] top-or-bottom flag. For trbflag = 'middle' the filter replaces values outside  |x-median(x)|>dsthreshold*options.tol) with the median. For trbflag = 'bottom' the filter replaces values outside (x-median(x))>dsthreshold*options.tol with the median. For trbflag = 'top' the filter replaces values outside (median(x)-x)>dsthreshold*soptions.tol with the median.
ntrim parameters
* '''ntrim''': when algorithm = 'meantrimmed' or 'mediantrimmed', (ntrim) is the input (n) to the functions MEANTRIMMED or MEDIANTRIMED {default = 2}. For windowmovement = 'bands', the filter is applied to a window of win(1) rows down each column followed by applying across a window of win(2) columns to each row. For windowmovement = 'rectangular', the filter is applied the windows of size win(1) by win(2) directly (uses more pixels in each filter than 'bands').


===See Also===
===See Also===


[[maxautofactors]], [[spatial_filter]], [[savgol2d]]
[[maxautofactors]], [[spatial_filter]], [[windowfilter]], [[madc]]

Latest revision as of 11:49, 5 December 2019

Purpose

Image or matrix (N-way) filtering (spatial filtering with a moving window)

Synopsis

xf = box_filter(x,win,options)

Description

BOX_FILTER is a spatial filter that filters and despises based on a moving window (or box). It tends to be slow compared to filter methods that can be vectorized.

Inputs

  • x = MxNxP data class 'double' or 'dataset'. If 'dataset' it must x.type=='image' (see BUILDIMAGE). If 'double' it must be MxNxP (P can = 1 or N-way arrays).
  • win = a 1 or 2 element vector of odd integers corresponding to the window width of the box filter. If scalar, (win) is set to win = [win win].

Outputs

  • xf = Filtered image class 'dataset' or matrix (or N-way array) class 'double.'

Options

options = a structure array with the following fields:

  • algorithm: [ {'mean'} | 'median' | 'max' | 'min' | 'despike' | 'meantrimmed' | 'mediantrimmed' ] governs filter method.
  • window movement: [ {'bands'} | 'rectangle' ], 'bands' moves vertically then horizontally over a single window across the image or slab, and 'rectangle' moves a rectangular window across the image or slab.

despike parameters

  • tol: { [] } if empty then despike uses the std(median(x)) within each window to define the tolerance within the window. If tol>0 scalar, then tol defines the tolerance for all the windows. If tol<=0, then tol is estimated by the mean absolute deviation of madc(x.data(:)) and is the tolerance used for all the windows (see MADC).
  • dsthreshold: [ {2} ] Threshold used for the 'despike' algorithm. In contrast to replacing all values with the meidan (e.g., for options.algorithm = 'median'), 'despike' replaces only values outside |x-median(x)|>options.dsthreshold*options.tol with the median. (see options.tol)
  • trbflag: [ {'middle'} | 'bottom' | 'top' ] top-or-bottom flag. For trbflag = 'middle' the filter replaces values outside |x-median(x)|>dsthreshold*options.tol) with the median. For trbflag = 'bottom' the filter replaces values outside (x-median(x))>dsthreshold*options.tol with the median. For trbflag = 'top' the filter replaces values outside (median(x)-x)>dsthreshold*soptions.tol with the median.

ntrim parameters

  • ntrim: when algorithm = 'meantrimmed' or 'mediantrimmed', (ntrim) is the input (n) to the functions MEANTRIMMED or MEDIANTRIMED {default = 2}. For windowmovement = 'bands', the filter is applied to a window of win(1) rows down each column followed by applying across a window of win(2) columns to each row. For windowmovement = 'rectangular', the filter is applied the windows of size win(1) by win(2) directly (uses more pixels in each filter than 'bands').

See Also

maxautofactors, spatial_filter, windowfilter, madc