Automatic Defects Classification with p-median Clustering Technique