2.1. Image grayscaling
In order to achieve the desired effect in stereo matching, it is necessary to first exclude the interference of noise, illumination, pixels and other factors as much as possible, so the image needs to be grayed out and image enhanced first, which can reduce the computation of the program processing procedure while still retaining the complete two-dimensional information of the image. In the RGB model, if R=G=B, then the color indicates a gray-scale color, where the value of R=G=B is called the gray-scale value, therefore, the grayscale image only one byte per pixel to store the gray-scale value, the gray-scale range of 0-255, when the grayscale is 255, it means the brightest; when the grayscale is 0, it means the darkest.
The benefits of grayscale are: compared to color images grayscale images take up less memory and run faster; after the grayscale image can visually increase the contrast and highlight the target area.
In this paper, the weighted average method is used to weight the R, G and B components according to the more suitable weights, as shown in Equation (2-1).The effect is shown in
Figure 2
2.2. Improved RANSAC algorithm
- (1)
Traditional algorithm
First, a matrix H of size three rows and three columns is created, so that the matrix is equal to one making the matrix normalized, and since there are eight unknown parameters, at least four sets of matching point pairs are needed to correspond to the location information.
where the points I
1 and I
2 correspond to the coordinates (x
1 ,y
1 ) and (x
2 ,y
2 ), respectively, while the size of z
1 , which is introduced into the chi-square equation, is 1.
The equation containing four matched pairs of points is then solved for.
The traditional RANSAC algorithm[
17] will first extract a part of matching points from the first matching result, and then construct a primary model to calculate the remaining matching points, and will classify the resulting point pairs into two types: matching original model and non-matching original model, where the point pairs matching original model are also called valid data, and the other type of point pairs are invalid data. Then, some matching pairs are extracted from the valid data, and the optimal model is obtained by continuing to distinguish good data from bad data in the above way and iterating continuously. Finally, the data model in the optimal model is solved, and the point pairs that do not meet the matching conditions are excluded to achieve data optimization.
- (2)
Improved mis-matching algorithm
Before the improvement of RANSAC algorithm, when matching feature points, there is a situation that a feature point is used multiple times to correspond to other points. In this paper, after optimizing the RANSAC algorithm, in order to improve the purification effect and reduce the situation that one point is used more than one time, this paper optimizes the RANSAC algorithm by setting the queue value and solving the single-response matrix. The flow chart of the algorithm is shown in
Figure 3.
Assume that the number of samples in the data is K, P is the model probability (confidence probability) of the local points at the iteration,
n is the minimum value to successfully solve the formula, N
i is the local points, N
t is the external points, and
is the ratio of the local points to the total number of points in the data, i.e.
The probability that there will always be an outlier during the iteration is
; the probability that at least one of the
n points is an outlier is [
19]:
.
Combining the two outlier probabilities yields the formula
When k → ∞, P → 1 general P = 0.995.
Among all matching points of the image to be extracted,
n are selected as sample points. According to the definition of parallax gradient, two pairs of matching points are selected among all the extracted data points for calculation and comparison, and the model parameters of the data matching points that meet the requirements are selected and the matching points that do not meet the requirements are excluded. The standard deviation of
k is then used to calculate the size of the standard deviation and compare the number of better matched points obtained for each group by.
The points with the best quality of matched points are then brought into the model parameters, and all outlier points are removed, and the remaining points with higher matching rates are used to calculate the model parameters. Then reverse search is performed to determine the correct rate of point pair matching, set the queue value using Hamming distance as a similarity measure, eliminate the feature points that do not meet the conditions, and then apply single response matrix verification to get more accurate matching points.
Repeat the above steps, and finally get the largest number of pairs of correct matching points in the set.
The image acquisition was performed by the camera in the middle of the trinocular vision system, and the relay was selected as the template reference for the feature matching experiments, and four cases of interference, rotation, interference plus rotation and scale change were designed. The experiments were conducted with the traditional SURF algorithm and the improved feature matching algorithm based on SURF+RANSAC, respectively, and the results are shown in
Figure 4. The correct alignment rate is used to indicate the performance of the algorithm feature descriptors. The higher the correct rate, the higher the accuracy of recognizing the target by the algorithm using the template image, using the directional consistency principle to obtain the matching logarithm. The number of correct matching pairs, the total matching pairs and the algorithm matching time for the initial image and the image to be detected with environmental influence in five cases are counted, as shown in
Table 2-1.
In
Figure 4, (a), (c), (e) and (g) are the matching results under different situations based on the traditional SURF algorithm, where the corresponding lines of left and right image matching are seriously skewed and quite misleading, with "one point corresponds to many points", "point to point cross matching [
18]"The matching results based on the improved algorithm of SURF+RANSAC combined with the principle of parallax gradient are shown in Figs. (b), (d), (f) and (h), which can be found intuitively that the feature point pairs of relay interface and label information and other details are more uniform, and there is no " One-to-many" phenomenon, the alignment effect is greatly improved and the robustness is better.