Algorithm 1: Finding and filtering the maximum and minimum point.

figure 31