# Neighborhood Operations

# Neighborhood Operations#

The result of a neighborhood operation is based on values of a certain group of pixels located near a given input pixel. The set of neighboring pixels is typically defined by a rectangular mask (or kernel) and anchor cell, specifying the mask alignment with respect to the position of the input pixel as shown in the following figure.

The anchor cell is a fixed cell within the kernel, which is used for positioning the kernel with respect to the currently processed pixel of the source image. The kernel is placed on the image in such a way that the anchor cell coincides with the input pixel. The anchor cell is specified by its coordinates anchor.x and anchor.y in the coordinate system associated with the top left corner of the kernel.

If position of the anchor cell is not specified explicitly in the function description, coordinates of the anchor are computed by the default formula:

`anchor.x=(kernel.width-1)/2`

`anchor.y=(kernel.height-1)/2`

where

kernel.width and kernel.height is the width and height of the filter kernel, respectively.