A three-dimensional image processing apparatus, 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, the apparatus comprising:
- a light projecting part configured to project incident light as structured illumination of a predetermined projection pattern from an oblique direction with respect to an optical axis of a below-described image capturing part;
- the image capturing part configured to acquire reflected light that is projected by the light projecting part and reflected on an inspection target, to capture a plurality of pattern projected images;
- a distance image generating part capable of generating a high-tone distance image based on the plurality of pattern projected images captured in the image capturing part;
- a tone conversion part configured to tone-convert the high-tone distance image generated by the distance image generating part to a low-tone distance image that has a lower number of tones than the number of tones of the high-tone distance image based on an initial tone conversion condition;
- a display part configured to display the low-tone distance image;
- a specifying part configured to specify an arbitrary position within the low-tone distance image displayed on the display part;
- a tone-converting parameter setting part configured to set a) a reference plane having the height information of the inspection target based on the arbitrary position specified by the specifying part and b) a gain value representing the number of tones per predetermined distance, wherein the tone conversion part updates the displayed low-tone distance image based on the reference plane and the gain value;
- a gain adjusting part configured to adjust the gain value;
- an inspection processing setting part configured to set an image inspection processing tool for performing the image inspection on the low-tone distance image in which the gain value is adjusted by the gain adjusting part and a height inspection processing tool for performing the height inspection on the high-tone distance image;
- and
- an inspection executing part configured to execute the image inspection processing on the low-tone distance image and the height inspection processing on the high-tone distance image.