A three-dimensional image processing program stored on a non-transitory computer readable medium, which is capable of acquiring a distance image that includes height information of an inspection target and also performing image processing based on the distance image,
- wherein the program, when executed by a computer, performing:
- a projection pattern setting function of previously setting a first projection pattern and a second projection pattern whose fringe direction is different from that of the first projection pattern as a plurality of projection patterns obtained by changing a fringe direction of a projection pattern for structured illumination;
- a distance image generating function of generating a first distance image and a second distance image based on a first pattern projected image and a second pattern projected image captured by projecting by a light projecting part incident light as structured illumination of the first projection pattern and the second projection pattern set by the projection pattern setting function, from an oblique direction with respect to an optical axis of an image capturing part and acquiring reflected light reflected on an inspection target;
- and
- an incorrect-height determining function of making comparison in height information of a corresponding portion of the inspection target between the first distance image and the second distance image, to determine height information of a portion where a difference not smaller than a predetermined value occurs as incorrect if this exists.