Adaptive threshold example