pedestal subtraction algorithm