Main Content

## Use Neighborhood Processing Subsystem Block Padding Options with Region of Interest

You can configure the Neighborhood Processing Subsystem block to pad values outside the input matrix using different padding methods. Use the parameters of the Neighborhood control block to configure the Neighborhood Processing Subsystem block behavior. This topic explains how the Padding option parameter interacts with other Neighborhood block parameters.

### Overview of Parameters

The Neighborhood Processing Subsystem block iterates over elements of a matrix. For each element, it processes a neighborhood of values surrounding that element. The Processing width and Processing offset parameters optionally configure a region of interest (ROI) within the image; the Neighborhood Processing Subsystem block iterates over only this subsection.

Some neighborhoods contain elements that extend beyond the ROI or input matrix. Because the Processing width and Processing offset parameters do not allow an ROI to extend beyond the input matrix, any value outside the input matrix is also outside the ROI. However, neighborhood elements can extend beyond the ROI while remaining inside the input matrix. The Padding option parameter specifies how the Neighborhood Processing Subsystem block populates values outside the input matrix. This parameter does not affect values inside the input matrix, even if those values are outside the ROI.

For more information about each block parameter, see Neighborhood. For an example of using the Processing width and Processing offset parameters to specify an ROI, see Specify Region of Interest for Neighborhood Processing.

### Example

Consider this matrix.

The blue region represents a 3-by-5 ROI specified by the Processing width parameter value `[3 5]` and Processing offset parameter value `[0 0]`. The orange region represents a 3-by-5 neighborhood, specified by the Neighborhood size parameter value `[3 5]`, around the value `11` in the input matrix. `a`, `b`, and `c` denote values outside the ROI. The Neighborhood Processing Subsystem block determines the values of `a`, `b`, and `c` depending on the padding option you select.

Padding optionValue at `a`Value at `b`Value at `c`
`Constant` (with Padding constant set to `0`)`0``0``16`
`Replicate``11``16``16`
`Symmetric``12``16``16`
`Circular``14``20``16`

`c` is always `16` because it corresponds to the value `16` in the input matrix. The Neighborhood Processing Subsystem block uses values from the input matrix when possible, even if those values are outside the ROI. `a` and `b` apply the rules of the padding option. If you select a padding option that reuses values from the input matrix, the Neighborhood Processing Subsystem block extrapolates the values of `a` and `b` from the full input matrix, even when the source of a reused value lies outside the ROI.