The image processing apparatus includes a boundary line extraction means that extracts a boundary line of a layer from an input image obtained by capturing an image of a target object composed of a plurality of layers. The boundary line extraction means is configured to first extract boundary lines at upper and lower ends of the target object, limit a search range using the extracted boundary lines at the upper and lower ends to extract another boundary line, limit the search range using an extraction result of the other boundary line to extract still another boundary line, and then sequentially repeat similar processes to extract subsequent boundary lines. In another aspect, the image processing apparatus includes a boundary line extraction means that extracts a boundary line of a layer from an input image obtained by capturing an image of a target object composed of a plurality of layers and a search range setting means that utilizes an already extracted boundary line extracted by the boundary line extraction means to dynamically set a search range for another boundary line. According to such an image processing apparatus and image processing method, boundary lines of layers can be extracted with a high degree of accuracy from a captured image of a target object composed of a plurality of layers.