Slider function to set threshold.  Must do more work on this as its slow so off load to a web worker and see if that helps