An apparatus includes a gaseous region extraction unit that extracts a gaseous region from a lumen image, a residue candidate region extraction unit that extracts a candidate of a residue region from the lumen image as a residue candidate region, a boundary candidate region detection unit that detects a boundary candidate region that includes a boundary between the gaseous region and the residue candidate region, a representative direction component obtaining unit that obtains a representative direction component representing a plurality of directional components of an image in the boundary candidate region, a boundary region detection unit that detects a boundary region that includes a boundary between the gaseous region and the residue region from the boundary candidate regions based on the representative direction component, and a residue region extraction unit that extracts the residue candidate region that includes the boundary region as the residue region.