Novel image similarity measurement in Automated Optical Inspection