Pattern Recognition for Defect Detection in Uncontrolled Environment Railway Applications