A region-setting unit sets, in an image, a region based on one reference point designated by a user in the image or a predetermined region as an extraction region. An edge extraction unit extracts an edge of the subject based on an image of the extraction region. When a plurality of edges are extracted, a display control unit causes a line indicating the plurality of extracted edges to be displayed on a display unit together with the image. An edge selection unit selects a reference edge from among the plurality of extracted edges based on an instruction from the user. A three-dimensional coordinate calculation unit calculates three-dimensional coordinates corresponding to points in the image. A reference line calculation unit calculates a reference line on a space based on the three-dimensional coordinates corresponding to points constituting the reference edge.