rewrite blockwise thresholding to use sources and sinks