I had created a segmentation algorithm that is able to detect levels above a certain threshold and alternates between 2 categories (red and green) as shown in Figure 1 below