Post-processing commonly used in stereo matching-left-right consistency Processing

Source: Internet
Author: User

Over the past period of time, I have also implemented several academic papers on stereo matching. The final display effect of the program is far inferior to that presented in the paper, however, self-compiled programs are strictly set according to the steps and parameters in the paper. Why? One of the reasons was found after searching for materials and reading papers online. If the program is okay, it may be because no additional processing steps are introduced in the paper, that is, some subsequent processing steps (post-processing), such as left-right consistency, LRC ).

 

Occlusion introduction:As the name implies, some vertices appear only in one image, but not in another image. In the stereo matching algorithm, if some special processing is not performed on the occlusion area, it is impossible to obtain the correct parallax of the occlusion point through the limited information provided by a single image. Occlusion points are usually contiguous areas.

 

LRC:The function is to implement occlusion detection and obtain the occlusion image corresponding to the left image. Specific Method: Based on the left and right input images, the left and right parallax images are obtained. For a vertex P in the left graph, the obtained apparent difference is D1, then the corresponding point of P in the right graph should be (p-d1), the apparent difference is recorded as d2. if | d1-d2 |> threshold, P indicates the occlusion point.


Occlusion Filtering:To obtain a binary occlusion image, it is necessary to assign a reasonable difference value to all black occlusion points. For the left image, occlusion points are generally located in the contact areas of the background area and the foreground area. The background is overwritten because the foreground is larger than the background offset. Specific Assignment Method: For an occlusion point P,Find the first unblocked point horizontally to the left and to the right, respectively., Recorded as PL and PR. The apparent difference of point P is assigned to the smaller value in the apparent difference between PL and PR.D (P) = min (D (PL), D (PR )).

Median Filter:This simple occlusion filtering has a significant effect in the assignment of occlusion areas, but it is highly dependent on the rationality and accuracy of the initial Parallax. In addition, horizontal stripes similar to the dynamic planning algorithm are displayed, so a median filtering step is followed to eliminate the stripe.


The Code is as follows (if you have any questions, you can ask me ):

# Include <math. h> # include "highgui. H "# include" CV. H "# include" time. H "# include <iostream> # define max (A, B) (a)> (B ))? (A): (B) # define min (A, B) (a) <(B ))? (A): (B) int main () {clock_t start, finish; unsigned long seconds; printf ("LRC"); Start = clock (); iplimage * leftimg; iplimage * rightimg; int scale; int W, H, NCHS, step, depth; leftimg = cvloadimage ("llaw.png",-1); rightimg = cvloadimage ("rraw.png ", -1); Scale = 16; depth = leftimg-> depth; W = leftimg-> width; H = leftimg-> height; NCHS = leftimg-> nchannels; step = leftimg-> widthstep/sizeof (uchar); // The final image iplimage * result = cvcreateimage (Cvsize (W, h), 8, 1); int X, Y, zeronum; int p_d_1, p_d_2; For (y = 0; y 


My test results:


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.