Add counting routine
merge with shunhao (add blur parameters)