This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

makelut

Create lookup table for use with bwlookup

Syntax

lut = makelut(fun,n)

Description

example

lut = makelut(fun,n) creates a lookup table. fun is a function that creates a numeric output from a 2-by-2 or 3-by-3 binary neighborhood, where n determines the neighborhood size. makelut creates a lookup table by passing all possible neighborhoods to fun, one at a time, and storing the outputs in vector lut.

Use the lookup table with bwlookup to perform nonlinear neighborhood filtering.

Examples

Make Lookup Table for 2-by-2 Neighborhood

Construct a lookup table for 2-by-2 neighborhoods. In this example, the function passed to makelut returns TRUE if the number of 1s in the neighborhood is 2 or greater, and returns FALSE otherwise.

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

Input Arguments

collapse all

Function handle, specified as a handle. The function must accept an n-by-n binary matrix of 1s and 0s as input and return a scalar.

For more information about function handles, see Create Function Handle (MATLAB).

Neighborhood size for the lookup table, specified as 2 or 3.

Output Arguments

collapse all

Lookup table, returned as a 16-element numeric vector when n is 2, or a 512-element numeric vector when n is 3.

Data Types: double

See Also

Introduced before R2006a