Added average filter with threshold