1. An image processing method comprising: obtaining right and left disparity images by using stereo matching, based on a pair of images captured by right and left cameras, respectively; performing filter processing on one of the right or left disparity images, by replacing a pixel value of a first pixel of a plurality of pixels forming a pixel region with a median of pixel values respectively of the plurality of pixels; and making a comparison, in the one of the right or left disparity images that have undergone the filter processing, between disparity values at mutually corresponding positions in the right and left disparity images and merging the disparity values of the right and left disparity images based on a comparison result, wherein, in the comparison, a disparity value of a particular pixel in the one of disparity images that has undergone the filter processing is compared with disparity values of a pixel corresponding to the particular pixel and a plurality of neighboring pixels in the other disparity image that have not undergone the filter processing.