Method of and device for inspecting images to detect defects