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

pub fn corner_sub_pix(
    image: &dyn ToInputArray,
    corners: &mut dyn ToInputOutputArray,
    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 inline formula to a point inline formula located within a neighborhood of inline formula is orthogonal to the image gradient at inline formula subject to image and measurement noise. Consider the expression:

block formula

where inline formula is an image gradient at one of the points inline formula in a neighborhood of inline formula . The value of inline formula is to be found so that inline formula is minimized. A system of equations may be set up with inline formula set to zero:

block formula

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

block formula

The algorithm sets the center of the neighborhood window at this new center inline formula 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 inline formula 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.