A method for inspecting a wafer, the method comprising: performing a training process for creating reference images, the training process comprising: capturing a plurality of images of a first wafer, the first wafer being of an unknown quality, each of the plurality of images of the first wafer being captured at a predetermined contrast illumination, each of the plurality of images of the first wafer comprising a plurality of pixels; determining a plurality of reference intensities for each of the plurality of pixels of each of the plurality of images of the first wafer; calculating a plurality of statistical parameters for the plurality of reference intensities of each of the plurality of pixels of each of the plurality of images of the first wafer; and selecting a plurality of reference images from the plurality of images of the first wafer based on the calculated plurality of statistical parameters, capturing an image of a second wafer, the second wafer being of an unknown quality; selecting a first reference image from the plurality of reference images; and comparing the captured image of the second wafer with the first reference image to thereby determine at least one of presence and type of defect on the second wafer. performing a training process for creating reference images, the training process comprising: capturing a plurality of images of a first wafer, the first wafer being of an unknown quality, each of the plurality of images of the first wafer being captured at a predetermined contrast illumination, each of the plurality of images of the first wafer comprising a plurality of pixels; determining a plurality of reference intensities for each of the plurality of pixels of each of the plurality of images of the first wafer; calculating a plurality of statistical parameters for the plurality of reference intensities of each of the plurality of pixels of each of the plurality of images of the first wafer; and selecting a plurality of reference images from the plurality of images of the first wafer based on the calculated plurality of statistical parameters, capturing a plurality of images of a first wafer, the first wafer being of an unknown quality, each of the plurality of images of the first wafer being captured at a predetermined contrast illumination, each of the plurality of images of the first wafer comprising a plurality of pixels; determining a plurality of reference intensities for each of the plurality of pixels of each of the plurality of images of the first wafer; calculating a plurality of statistical parameters for the plurality of reference intensities of each of the plurality of pixels of each of the plurality of images of the first wafer; and selecting a plurality of reference images from the plurality of images of the first wafer based on the calculated plurality of statistical parameters, capturing an image of a second wafer, the second wafer being of an unknown quality; selecting a first reference image from the plurality of reference images; and comparing the captured image of the second wafer with the first reference image to thereby determine at least one of presence and type of defect on the second wafer. <EOS>