Image Processing Toolbox | ![]() ![]() |
Construct a lookup table for use with applylut
Syntax
Description
lut = makelut(fun,n)
returns a lookup table for use with applylut
. fun
is either a string containing the name of a function or an inline function object. The function should take a 2-by-2 or 3-by-3 matrix of 1's and 0's as input and return a scalar. n
is either 2 or 3, indicating the size of the input to fun
. makelut
creates lut
by passing all possible 2-by-2 or 3-by-3 neighborhoods to fun
, one at a time, and constructing either a 16-element vector (for 2-by-2 neighborhoods) or a 512-element vector (for 3-by-3 neighborhoods). The vector consists of the output from fun
for each possible neighborhood.
lut = makelut(fun,n,P1,P2,...)
passes the additional parameters P1,P2,...,
to fun
.
Class Support
lut
is returned as a vector of class double
.
Example
In this example, the function returns 1 (true) if the number of 1's in the neighborhood is 2 or greater, and returns 0 (false) otherwise. makelut
then uses the function to construct a lookup table for 2-by-2 neighborhoods.
See Also
![]() | label2rgb | makeresampler | ![]() |