Main Content

applylut

Neighborhood operations on binary images using lookup tables

applylut is not recommended. Use bwlookup instead.

Description

A = applylut(BW,lut) performs a 2-by-2 or 3-by-3 neighborhood operation on binary image BW by using a lookup table, lut. The lookup table consists of the output values for all possible 2-by-2 or 3-by-3 neighborhoods.

example

Examples

collapse all

Create the lookup table.

 lutfun = @(x)(sum(x(:))==4);
 lut = makelut(lutfun,2);

Read image into the workspace and then apply the lookup table to the image. An output pixel is on only if all four of the input pixel's neighborhood pixels are on.

 BW1 = imread("text.png");
 BW2 = applylut(BW1,lut);

Show the original image and the eroded image.

imshow(BW1)

Figure contains an axes object. The hidden axes object contains an object of type image.

imshow(BW2)

Figure contains an axes object. The hidden axes object contains an object of type image.

Input Arguments

collapse all

Input image, specified as a 2-D binary image. For numeric input, any nonzero pixels are considered to be 1 (true).

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Lookup table of output pixel values, specified as a 16- or 512-element vector as returned by makelut.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Output Arguments

collapse all

Output image, returned as a grayscale or binary image whose distribution of pixel values are determined by the content of the lookup table, lut. The output image J is the same size as the input image I.

  • If all elements of lut are 0 or 1, then A has data type logical.

  • If all elements of lut are integers between 0 and 255, then A has data type uint8.

  • For all other cases, A has data type double.

Data Types: double | uint8 | logical

Algorithms

collapse all

applylut performs a neighborhood operation on a binary image by producing a matrix of indices into lut, and then replacing the indices with the actual values in lut. The specific algorithm used depends on whether you use 2-by-2 or 3-by-3 neighborhoods.

Version History

Introduced before R2006a

collapse all

See Also