[][src]Function opencv::imgproc::corner_sub_pix

pub fn corner_sub_pix(
    image: &Mat,
    corners: &mut Mat,
    win_size: Size,
    zero_zone: Size,
    criteria: &TermCriteria
) -> Result<()>

Refines the corner locations.

The function iterates to find the sub-pixel accurate location of corners or radial saddle points, as shown on the figure below.

image

Sub-pixel accurate corner locator is based on the observation that every vector from the center q to a point p located within a neighborhood of q is orthogonal to the image gradient at p subject to image and measurement noise. Consider the expression:

\epsilon _i = {DI_{p_i}}^T \cdot (q - p_i)

where {DI_{p_i}} is an image gradient at one of the points p_i in a neighborhood of q . The value of q is to be found so that \epsilon_i is minimized. A system of equations may be set up with \epsilon_i set to zero:

\sum _i(DI_{p_i} \cdot {DI_{p_i}}^T) \cdot q - \sum _i(DI_{p_i} \cdot {DI_{p_i}}^T \cdot p_i)

where the gradients are summed within a neighborhood ("search window") of q . Calling the first gradient term G and the second gradient term b gives:

q = G^{-1} \cdot b

The algorithm sets the center of the neighborhood window at this new center q and then iterates until the center stays within a set threshold.

Parameters

  • image: Input single-channel, 8-bit or float image.
  • corners: Initial coordinates of the input corners and refined coordinates provided for output.
  • winSize: Half of the side length of the search window. For example, if winSize=Size(5,5) , then a (52+1) \times (52+1) = 11 \times 11 search window is used.
  • zeroZone: Half of the size of the dead region in the middle of the search zone over which the summation in the formula below is not done. It is used sometimes to avoid possible singularities of the autocorrelation matrix. The value of (-1,-1) indicates that there is no such a size.
  • criteria: Criteria for termination of the iterative process of corner refinement. That is, the process of corner position refinement stops either after criteria.maxCount iterations or when the corner position moves by less than criteria.epsilon on some iteration.