added more options for reference image, tolerance and window size. Added drawCentroids function for debugging