"OPENCV" Stereo matching algorithm basic implementation of SSD, NCC and ASW

Source: Internet
Author: User

Requirements: To match the left and right views, and then output the two disparity map (parallax map)

e.g.

Left view, right view (two images are the same size, only the perspective transform in the horizontal direction)

The standard parallax map is as follows:

  SSD (sum of squared differences) implementations:

      

1. Turn left and right view into CV_8UC1 single channel image

Can directly refer to the API implementation of OPENCV, write a three-channel averaging or according to the following formula to convert the function, the results have little impact

      

2. Processing for each pixel

Suppose dmax=79, for each D value of each pixel, calculates the sum of the squared deviations of the pixel gray values of the left and right views within the patch (sliding window), and then records the value with its corresponding D value

Here you can use Vector<pair<sum, d>> to store the results

3. Take the minimum sum value corresponding to D as the final output of the disparity map corresponding to the gray value of the point

Result:5*5 window, the bad point rate is 24, 72%, 25.78%, respectively

  NCC (normalized cross-correlation) achieves:

  

1. Similarly, turn the left and right views into a single-channel grayscale image

2. Then for each pixel processing, for each corresponding to the D value, first calculate the numerator, in the calculation of the denominator, and finally the numerator/denominator value and the corresponding D value into the vector

3. The D value corresponding to the maximum value in the vector is the gray value of disparity map at that point.

result:5*5 window Bad point rate: 23.64%, 24.2% slightly better than SSD

  ASW (Adaptive support Weight) implements:

  

  

  

This is achieved by the formula, relatively simple, if the window is large enough, the ASW will be better, but it will be very slow

But when calculating the CPQ value in the middle, we mainly convert the BGR model into lab model calculation.

    

result:5*5 window size, bad point rate: 31.33%, 31.39%

33*33 window size, bad point rate: 19.44%, 20.75% (however, ran 9242 seconds ... You can feel it yourself ...

Code implementation: Tidy up after two days to paste up.

"OPENCV" Stereo matching algorithm basic implementation of SSD, NCC and ASW

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.