Created a getImageMaskForRanges function which can handle multiple threshold ranges eg. red has two ranges because it wraps around from 179 to 0