The common post-processing in stereo matching-left and right consistency processing

Source: Internet
Author: User
Tags min printf

In the past a period of time, I have also achieved several three-dimensional matching of the academic papers, the final results of the program is far less than the results presented in the paper, but the program is written in strict accordance with the steps and parameters set in the paper, why. After searching the Internet for information and reading papers, one of the reasons was found. If the program is not a problem, it may be that the paper does not introduce additional processing steps, that is, some subsequent processing steps (post-processing), such as left and right consistency detection (Left-right CONSISTENCY,LRC).

occlusion Introduction: As the name implies, some points appear only in one image, but not in another image. In the stereo matching algorithm, it is impossible to get the correct parallax of the occlusion point by the limited information provided by the single image if it does not do some special processing for the occlusion area. The occlusion point is usually a contiguous area.

LRC: The role is to achieve occlusion detection, the left image corresponding to the occlusion. Specific method: According to the left and right two input images, the left and right two parallax maps were obtained. For a point p in the left image, the parallax value is D1, so the corresponding point of p in the right image should be (P-D1), and its parallax value is recorded as D2. If the |d1-d2|>threshold,p is marked as a occlusion point.


occlusion filtering: to get a two value occlusion image, it is necessary to give reasonable parallax value to all black occlusion points. For the left graph, the occlusion point usually exists in the background area and in the foreground area contact place. Occlusion is generated because the foreground is larger than the background offset, which obscures the background. Specific assignment method: For a occlusion point P, respectively, to the left and to the right to find the first non-occlusion point , recorded as PL, pr. The parallax value of the point P is assigned to the smaller value of the PL and PR parallax values. d (P) =min (d (PL), d (PR)).

Median Filter: This simple occlusion filter has significant effect on the assignment of Occlusion area, but the rationality and precision of initial parallax are high. There is also a horizontal stripe similar to the dynamic programming algorithm, so it is often followed by a median filtering step to eliminate streaks.


The code is as follows (ask me if you have questions):

#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) ((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);
	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.