The invention provides a stereo matching method based on an improved gradient and an adaptive window, and aims to solve the problem that an existing local stereo matching algorithm is low in precision and is influenced by amplitude distortion easily. Firstly, on the basis that a traditional gradient vector only contains amplitude information, phase information is introduced, conversion is carried out on the original matching cost, and abnormal values are further eliminated. Then, the adaptive window can be built through the criss-cross adaptive window generation method according to the color and spatial position relation between adjacent pixels, wherein a large window is provided for a low-texture area to improve matching precision, a small window is generated in a high-texture area to protect detail information of the edge of an object and the like, and the aggregated cost is selected according to the Winner-Takes-All strategy so that a disparity value corresponding to the minimum value of the total cost can serve as an initial matching result. Finally, a disparity refinement method based on a local disparity histogram is provided, and a high-precision disparity map is obtained. As is shown in experimental results, the stereo matching method is high in machining precision and has high robustness under the condition of amplitude distortion.