MATLAB exercise program (Stereo correlation block matching)

Source: Internet
Author: User

There are two types of stereo sensing Point Matching: one is low-level pixel-level matching, and the other is high-level feature-level matching.

This section describes the underlying pixel-level matching.

You can use the camera to move two images in parallel, which are actually two images that are detected by your eyes.

The principle is that in a certain window, the two images have the same horizontal parallax, And the pixel similarity between the two local Windows can calculate the depth of the current pixel.

Let's take a look at the effect first:

Left. IMG right. img

Depth. img

The following criteria are used to determine pixel similarity:

In all the formulas (unofficial formulas, written on your own), DS is the pixel block (left) in the source image, and DD is the pixel block (right) of the target image ), I is the distance to search for depth.

Of course, the left and right sides are the same.

1. The sum of absolute differencse (SAD) formula is as follows:

2. The Root Mean Squared Error (RMS) formula is as follows:

3. The sum of squared differences (SSD) formula is as follows:

4. the normalized cross correlation (NCC) formula is as follows:

5. The sum of hamming distances (SHD) formula is as follows:

The BIT () in formula 5 indicates the number of 1 contained after the pixel is converted to binary. The entire formula indicates that the two local images are first different or a bit, then count the number of the first after all pixels are converted to binary. Just take the minimum one.

I used only MATLAB to implement the first formula. Others are similar.

The Code is as follows:

Clear all; close distance '); [m n] = size (left); W = 3; % template radius depth = 5; % maximum offset distance, it is also the maximum depth distance imgn = zeros (m, n); for I = 1 + W: M-W for j = 1 + W + depth: n-w tmp = []; Lwin = left (I-W: I + W, J-W: J + W); For k = 0:-1: -Depth rwin = right (I-W: I + W, J-W + K: J + W + k); diff = Lwin-rwin; TMP = [TMP sum (ABS (diff (:))]; end [junk imgn (I, j)] = min (TMP ); % obtain the minimum index endendimshow (imgn, [])

Not all implementations are because all implementations can be found on this foreigner's blog (which needs to be turned over to the wall), so I will not do that.

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.