1. An inspection apparatus performing template matching to a search image; comprising: a template cutout means for cutting out a template from a template selection image; a marginal similarity calculation means for calculating marginal similarity distribution information, which is a similarity distribution of the template selection image to the template; a search image similarity calculation part for calculating search image similarity distribution information, which is a similarity distribution of the search image to the template; a similarity distribution-to-similarity distribution similarity calculation means for calculating similarity distribution-to-similarity distribution similarity information between the marginal similarity distribution information and the search image similarity distribution information; and a matching position determination part for determining a matching position based on the similarity distribution-to-similarity distribution similarity.