'Take the value in an ROI, calculate the average / peak hue
and then set the output image roi to the value.'

def _CopyAvg(self, src, dst, roi, levels, levels_f, mode):

    if mode:
        h = src[roi[0]:(roi[0] + roi[2]), roi[1]:(roi[1] + roi[3])].hueHistogram()
        myHue = np.argmax(h)
        C = (float(myHue), float(255), float(255), float(0))
        cv.SetImageROI(dst, roi)
        cv.AddS(dst, c, dst)
        cv.ResetImageROI(dst)
    else:
        cv.SetImageROI(src.getBitmap(), roi)
        cv.SetImageROI(dst, roi)
        avg = cv.Avg(src.getBitmap())
        avg = (float(avg[0]), float(avg[1]), float(avg[2]), 0)
        if (levels is not None):
            avg = ((int((avg[0] / levels)) * levels_f), (int((avg[1] / levels)) * levels_f), (int((avg[2] / levels)) * levels_f), 0)
        cv.AddS(dst, avg, dst)
        cv.ResetImageROI(src.getBitmap())
        cv.ResetImageROI(dst)
