Optimal lighting for defect detection: illumination systems, machine learning, and practical verification