ArrayFilter

ArrayFilter[f,array,r]

applies f to all range-r blocks in the specified array.

ArrayFilter[f,array,{r1,r2,}]

applies f to blocks with ranges r1, r2, in successive dimensions.

ArrayFilter[f,array,template]

applies f over blocks specified by the position of 1s in the array template.

Details and Options

  • ArrayFilter[f,array,] requires that array is full array to a certain depth.
  • ArrayFilter[f,array,r] applies f to all overlapping blocks of elements in array.
  • Both array and template can be SparseArray objects.
  • With ArrayFilter[f,array,template], neighborhood elements corresponding to 0s of template are replaced with Missing[] before being passed to f.
  • ArrayFilter has the option Padding, which specifies how neighborhoods should be formed at the edges of the array. The following settings can be used:
  • Nonereturns a smaller array
    valuse val for padding
    "Fixed"repeat edge elements (default)
    "Periodic"periodic in each dimension

Examples

open allclose all

Basic Examples  (3)

Apply f to each element of a list and its range-1 neighbors:

Apply f to each element of a list and its range-2 neighbors:

Apply f to all 3x3 blocks of range-1 neighbors around each element:

Show as matrices:

Scope  (4)

Specify length-3 blocks using a template:

Specify length-3 blocks using a template where the center element is not considered:

Specify length-3 blocks using a template where only the left element is considered:

Use DeleteMissing to remove elements according to a specified template:

Options  (6)

Padding  (6)

By default, fixed padding is used for neighborhoods at the border:

Pad neighborhoods using a constant value:

Periodic padding for a list:

Periodic padding in all dimensions for a matrix:

Show as a matrix:

With Padding->None, ArrayFilter only visits neighborhoods entirely inside the array:

Use padded values with different paddings:

With Padding->None, empty lists are returned when the neighborhood size is larger than the input:

A 2x2 matrix has no 3x3 neighborhoods:

A 2x2 matrix with a 1x3 template:

Applications  (5)

Compute successive differences of elements:

Compute a moving average with runs of 3 elements using a range-1 neighborhood:

Compute a moving median of all values in each 3x3 neighborhood of a matrix:

Compute a moving quantile for some data:

Implement a 2D additive cellular automaton:

Properties & Relations  (1)

Templates with even dimensions effectively allow maximal overhang at the beginning:

Wolfram Research (2015), ArrayFilter, Wolfram Language function, https://reference.wolfram.com/language/ref/ArrayFilter.html.

Text

Wolfram Research (2015), ArrayFilter, Wolfram Language function, https://reference.wolfram.com/language/ref/ArrayFilter.html.

CMS

Wolfram Language. 2015. "ArrayFilter." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ArrayFilter.html.

APA

Wolfram Language. (2015). ArrayFilter. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ArrayFilter.html

BibTeX

@misc{reference.wolfram_2024_arrayfilter, author="Wolfram Research", title="{ArrayFilter}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/ArrayFilter.html}", note=[Accessed: 05-October-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_arrayfilter, organization={Wolfram Research}, title={ArrayFilter}, year={2015}, url={https://reference.wolfram.com/language/ref/ArrayFilter.html}, note=[Accessed: 05-October-2024 ]}