Improved run time by pushing all computations in segmentHSV into 1 loop.