Main Content

makelut

Create lookup table for use withbwlookup

Description

example

lut= makelut(fun,n)creates a lookup table.funis a function that creates a numeric output from a binary neighborhood of sizen-by-n. The function creates a lookup table by passing all possible neighborhoods tofun, one at a time, and storing the outputs in vectorlut.

Use the lookup table withbwlookupto perform nonlinear neighborhood filtering.

Examples

collapse all

Create a lookup table for 2-by-2 neighborhoods. In this example, the function passed tomakelutreturnstrueif the number of1s in the neighborhood is 2 or greater, and returnsfalseotherwise.

f = @(x) (sum(x(:)) >= 2); lut = makelut(f,2)
lut =16×10 0 0 1 0 1 1 1 0 1 ⋮

Input Arguments

collapse all

Function handle, specified as a handle. The function must accept ann-by-nbinary matrix of1s and0s as input and return a scalar.

For more information about function handles, seeCreate Function Handle.

Neighborhood size for the lookup table, specified as2or3.

Output Arguments

collapse all

查找表,返回16-element numeric vector whennis2, or a 512-element numeric vector whennis3.

Data Types:double

Version History

Introduced before R2006a

See Also