rewrote and generalized ocl::threshold