This paper presents the Contrast Invariant and Affine Optical Flow (CIAO), a dense area-based sub-pixel image matching algorithm. CIAO does not force the estimated disparity field between two images to be smooth and allows for contrast and brightness changes. It is robust to drastic changes in the images' content thanks to an adaptive weighting of the neighboring pixels. In addition, the proposed model considers local affine displacements instead of simpler translations. CIAO proves particularly useful to extract high quality, high accuracy, and high density disparity maps from pairs of stereoscopic images. Comparative results with real and synthetic data are provided.