OpenCV User Manual Image Processing Section (1): Gradient, Edge and Corners (Chinese Translation)

xiaoxiao2021-03-06  69

Below is the image processing section of the OpenCV user manual: gradient, edge and angular point (Chinese translation), there is a mistake welcome, original:

http://www.assuredigit.com/incoming/sourcecode/opencv/chinese_docs/ref/opencvref_cv.htm

Note: This chapter describes some of the functions of image processing and analysis. Most functions are for two-dimensional arrays. So we use the array to describe "images", and the image does not have to be IPLIMAGE, but also CVMAT's or CVMATND.

Gradient, edge and angle

Translation: Hunnish, abeer

Sobel

Use the extended Sobel operator to calculate the first order, second, third-order or mixed image difference

Void Cvsobel (Const Cvarr * SRC, CVARR * DST, INT XORDER, INT YORDER, INT Aperture_size = 3);

SRC

Enter the image.

DST

Output image.

xorder

X? Directional difference

yorder

The difference between the Y? direction

Aperture_size

Expand

The Sobel core must be 1, 3, 5 or 7. In addition to the size of 1, in other cases, the aperture_size × aperture_size can separate the kernel will be used to calculate the difference. The 3x1 or 1x3 kernel (not a Gaussian smoothing operation) is used for Aperture_Size = 1. There is a special variable? CV_SCHARR (= -1), corresponding to the 3x3 Scharr filter, can give more accurate results than 3x3 Sobel filtering. The SCHARR filter coefficient is:

| -3 0 3 |

| -10 0 10 |

| -3 0 3 |

Correct

The x-direction and the transposed matrix on the Y-direction.

The function CVSobel calculates the image difference by convolving the image with the corresponding kernel:

DST (x, y) = DXORDER YODERSRC / DXXORDER • DYYORDER | (X, Y)

The Sobel operator combines Gaussian smooth and differential to increase the calculation results to noise resistance. Normally, the function call uses the following parameters (xorder = 1, yorder = 0, Aperture_Size = 3) or (Xorder = 0, Yorder = 1, Aperture_SIZE = 3) to calculate image differences in the first order x- or Y-direction. The first case corresponds to:

| -1 0 1 |

| -2 0 2 |

| -1 0 1 |

nuclear. Second corresponding

| -1 -2 -1 |

| 0 0 0 |

| 1 2 1 |

oral

| 1 2 1 |

| 0 0 0 |

| -1 -2 -1 |

Nuclear, it relies on the definition of the image origin (Origin is defined by the IPLImage structure). Image scale transformation is not performed. Therefore, the output image is usually larger than the input image. To prevent overflow, when the input image is 8 bits, the output image is required to be 16 bits. The resulting image can be converted to 8 bits with a function CVConvertscale or CVConvertscaleabs. In addition to the 8-bit image, the function also accepts 32-bit floating point images. All input and output images must be single channels, and the image size or ROI size is consistent.

Laplace

Calculate the image of Laplacian?

Void CVLAPLACE (Const Cvarr * SRC, CVARR * DST, INT Aperture_size = 3);

SRC

Enter the image.

DST

Output image.

Aperture_size

Nuclear size

(As defined in CVSobel).

Function CVLAPLACE calculates the Laplacian of the input image. The method is the second-order x- and y-difference and: DST (x, y) = d2src / dx2 d2src / dy2

The fastest calculation result is given to Aperture_Size = 1, which is equivalent to the following cores to make convolution:

| 0 1 0 |

| 1 -4 1 |

| 0 1 0 |

Similar to the CVSobel function, it is not a scale transformation of the image, and supports the input, the output image type is consistent.

Canny

Edge detection by Canny algorithm

Void Cvcanny (Const Cvarr * Image, Cvarr * Edges, Double Threshold1,

Double Threshold2, int Aperture_size = 3);

Image

Enter the image.

EDGES

Output edge image

Threshold1

First threshold

Threshold2

Second threshold

Aperture_size

Sobel operator kernel size (see CVSobel).

The function Cvcanny uses the Canny algorithm to find the edge of the input image and identify these edges in the output image. Small threshold Threshold1 is used to control the edge connection, and the large threshold is used to control the initial segmentation of the strong edge.

PrecornerDetect

Calculation characteristics for angular point detection

Void CvpRecornerDetect (const cvarr * image, cvarr * corners, int Aperture_size = 3);

Image

Enter the image.

Corners

Array for saving angular coordinates

Aperture_size

The nuclear size of the Sobel operator (see cvsobel).

Function CvPrecornerDetect calculation function DX2DYY DY2DXX - 2DXDYDXY where D? Indicates a first-order image difference, D ?? represents a second-order image difference. The angle is considered to be the local maximum of the function:

// Assuming That the Image IS floating point number

IPLIMAGE * CORNERS = CVCloneImage (Image);

IPLIMAGE * DILATED_CORNERS = CVCloneImage (image);

IPLIMAGE * CORNER_MASK = CVCReateImage (Cvgetsize (Image), 8, 1);

CvpRecornerDetect (Image, Corners, 3);

CVDilate (Corners, Dilated_Corners, 0, 1);

Cvsubs (Corners, Dilated_Corners, Corners);

CVCMPS (Corners, 0, Corner_Mask, CV_CMP_GE);

CVRELEASEIMAGE (& CORNERS);

CVRELEASEIMAGE (& DiLated_Corners);

CorneReiGenvalsandVecs

Calculate the characteristic value and feature vector of the image block for angular detection

Void CvcorneReigenvalsandVECS (Const Cvarr * Image, Cvarr * Eigenvv,

INT block_size, int Aperture_size = 3);

Image

Enter the image.

Eigenvv

The array of saved results. Must be wide than the input image

6 times.

Block_size

Neighborhood

(See discussion).

Aperture_size

The nuclear size of the Sobel operator (see CVSobel).

For each pixel, function CVCorneReiGenvalsandVecs consider the neighbor s (p) of block_size × block_size size, then calculate the differential correlation matrix: | SUMS (P) (Di / DX) 2 SUMS (P) (Di / DX • DI / DY) |

M = | |

SUMS (P) (DI / DX • DI / DY) SUMS (P) (DI / DY) 2 |

It then calculates the characteristic value and feature vectors of the matrix, and stores these values ​​in the output image as follows (λ1, λ2, X1, Y1, X2, Y2), where λ1, λ2 - m, is not sorted (x1) , Y1) - Feature vector, λ1 (x2, y2) - feature vector, λ2

CornermineiGenval

Calculate the minimum feature value of the gradient matrix for angular detection

Void CvcornerMineiGenval (const cvarr * image, cvarr * eigenval, int block_size, int Aperture_size = 3);

Image

Enter the image.

Eigenval

Image of saving minimum feature values

Consistent with the input image size

Block_size

Neighborhood

(See discussion

CvcorneReigenvalsandVecs).

Aperture_size

The core size of the Sobel operator (see CVSobel). When the input image is a floating point number format, the parameter represents the number of floating point filters for calculating the difference.

Similar to CVCornerMineiGenVal, but it only calculates and stores minimum feature values ​​for each pixel point differential correlation matrix, that is, the previous function of MIN (λ1, λ2)

Findcornersubpix

Accurate angular position

Void Cvfindcornersubpix (const cvarr * image, cvpoint2d32f * corners,

INT Count, Cvsize Win, Cvsize Zero_zone,

CVTERMCRITERIA CRITERIA);

Image

Enter the image.

Corners

Input angle point initial coordinates, also stores accurate output coordinates

count

Angular point

Win

Search half size of the window. in case

Win

= (5, 5) So use 5 * 2 1 × 5 * 2 1 = 11 × 11 size search window

ZERO_ZONE

Half size of the dead zone, the dead zone is a region where the center of the search area is doing and calculates. It is used to avoid certain possible strangeness that appear from autocorrelation matrices. Value

(-1, -1) indicates no dead zone.

criteria

The termination condition of the iterative process of the angle point. The determination of the angular point position, or the number of iterations is greater than a set value, or the accuracy reaches a set value.

criteria

Can be the maximum number of iterations, or the accuracy

The function CVFindCornersubpix discovers the angular position of the sub-pixel accuracy by iteration, or the radial saddle point shown in the figure.

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.:

εi = Dipit • (Q-Pi)

where DIpi is the image gradient at the one of the points pi in a neighborhood of q The value of q is to be found such that εi is minimized A system of equations may be set up with εi 'set to zero:.. sumi ( DIPI • Dipit) • Q - SUMI (Dipi • Dipit • Pi) = 0

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 • B

...................

Goodfeaturestotrack

Determine the strong angle of the image

Void Cvgoodfeaturestotrack (Const Cvarr * Image, Cvarr * EIG_IMAGE, CVARR * TEMP_IMAGE,

CvpoinT2D32F * Corners, Int * Corner_count,

Double Quality_Level, Double Min_Distance,

Const Cvarr * mask = null);

Image

Enter an image,

8-bit or floating point 32- bits, single channel

EIG_IMAGE

Temporary floating point

32-bit image, the size is consistent with the input image

TEMP_IMAGE

Another temporary image, format and size

EIG_IMAGE

Consistent

Corners

Output parameters, detected angle points

Corner_count

Output parameters, the number of angular points detected

Quality_level

Multiplication factor of maximum minimum characteristic value. Define the minimum mass factor that accepts image angle points.

min_distance

Limit factor. The minimum distance of the corner point. use

Euclidian distance

Mask

ROI: Issue of interest. The function calculates the angle in the ROI. If MASK is NULL, select the entire image.

Functions CvgoodFeaStotrack look for angular points with large feature values ​​in the image. This function, first calculate the minimum eigenval value of each pixel point of the input image with CVCORNERMINEiGENVAL, and store the result in the variable eiG_Image. Then do not maximum compression (only the local maximum of the 3x3 neighborhood) is retained. The next step will be less than Quality_LEVEL • Max (EIG_IMAGE (X, Y)). Finally, the function ensures that there is enough distance between all discovery angles (the strongest angle point, then check the distance between the new angular point and the angular point is greater than min_distance).

转载请注明原文地址:https://www.9cbs.com/read-120625.html

New Post(0)