1. A method of detecting a defect, comprising: illuminating a sample with a light; detecting light from the specimen which is illuminated by the light, and forming an image by processing the detected light; extracting a defect candidate by processing the image of the sample formed in the detecting, and determining an inspection condition by using images including the image of the sample acquired in the detecting, a partial image including the extracted defect candidate and a reference image which corresponds to the partial image including the defect candidate.