An endoscopic stereo matching method and apparatus using a direct attenuation model is provided. A method for generating a depth image according to an embodiment includes: generating a stereo image; and estimating a depth image from the stereo image based on an attenuation trend of light of an illumination used to generate the stereo image. Accordingly, a dense depth image can be obtained by using images obtained from a capsule endoscope, and thus the geometric structure of the inside of the GI tract can be estimated.