Main Content

Neighborhood

Control block for Neighborhood Processing Subsystem

Description

The Neighborhood block serves as a control block for the Neighborhood Processing Subsystem block. The Neighborhood Processing Subsystem block iterates over an input matrix. At each iteration, the inport inside the subsystem receives a small matrix representing a configurable window of elements around one element of the input matrix. Use the Neighborhood block parameters to configure the window dimensions and the size of the output matrix.

Parameters

expand all

Configure the dimensions of the neighborhood window that the subsystem receives at each iteration. For example, consider this input matrix:

[12345678910111213141516171819202122232425]

.

If you set Neighborhood size to [3 3], then on the seventh iteration, the Neighborhood Processing Subsystem block receives this 3-by-3 window that surrounds the seventh element:

[123678111213]

.

Programmatic Use

Block Parameter: NeighborhoodSize
Type: array
Values: [3 3] | '<array>'
Default: [3 3]

Configure the dimensions of the output matrix.

  • Same –– The output matrix uses the same dimensions as the input matrix. For elements near the edges, the neighborhood extends beyond the input matrix. Use the Padding option parameter to configure how to pad elements outside the input matrix.

  • Full –– The output matrix is larger than the input matrix. It includes an element for every neighborhood that includes at least one element from the input matrix, even if the neighborhood center is outside the input matrix. Use the Padding option to configure how to pad elements outside the input matrix.

  • Valid –– The output matrix is smaller than the input matrix. The output matrix includes only the elements whose neighborhoods fall entirely within the input matrix.

Programmatic Use

Block Parameter: OutputSize
Type: character vector
Values: 'Same' | 'Full' | 'Valid'
Default: 'Same'

Configure how to pad values outside the input matrix. When you use the Full and Same output sizes, some neighborhoods extend beyond the input matrix and use these padded values.

To fully illustrate the logic of each padding option, each example graphic shows the 5-by-5 input matrix padded with 5-by-5 matrices. In practice, not every padded value is necessarily part of a neighborhood, depending on the Neighborhood size and Output size parameters. For example, if you set Neighborhood size to [3 3] and Output size to Same, the subsystem uses only the innermost layer of padded values.

  • Constant –– Use a configurable constant value for elements outside the input matrix. For example, this matrix uses a constant value of 0:

    5-by-5 matrix containing the integers from 1 to 25. The values outside the matrix are each set to 0..

  • Replicate –– Extend the values of the edge parameters:

    5-by-5 matrix containing the integers from 1 to 25. The values outside the matrix are each set to the nearest value from the input matrix..

  • Symmetric –– Mirror the input matrix:

    5-by-5 matrix containing the integers from 1 to 25. The values outside the matrix mirror those from the input matrix..

  • Circular –– Repeat the input matrix in a tiled pattern:

    5-by-5 matrix containing the integers from 1 to 25. The values outside the matrix repeat the pattern from the input matrix..

Programmatic Use

Block Parameter: PaddingOption
Type: character vector
Values: 'Constant' | 'Replicate' | 'Symmetric' | 'Circular'
Default: 'Constant'

Dependencies

To enable this parameter, set Output size to Same or Full.

Configure the value to use for the Constant padding option.

Dependencies

To enable this parameter, set Padding option to Constant.

Programmatic Use

Block Parameter: PaddingConstant
Type: scalar
Values: 0 | '<scalar>'
Default: 0

Extended Capabilities

Version History

Introduced in R2022b