Exemplo n.º 1
0
def tstRGB_YCbCr_RGB():
    """ RGB to YCbCr back to RGB full range test """
    report.write("\n*** RGB->YCbCr->RGB test ***")
    nberr = nbt = 0
    random_pick = unit_tests.RandPickInRange(100000, 500000)
    for rtst, gtst, btst in itertools.product(range(256), range(256), range(256)):
        nbt += 1
        colYCbCr = cCV.RGBtoYCbCr(rtst, gtst, btst)
        colRGB = cCV.YCbCrtoRGB(*colYCbCr)

        random_pick.increment()
        if random_pick.compare() is True:
            random_pick.restart()
            report.write("\ncase pick -> From: {}-{}-{} / To: {} / Back: {}".format(rtst, gtst, btst, colYCbCr, colRGB))

        if colRGB > (rtst + thr, gtst + thr, btst + thr) or colRGB < (rtst - thr, gtst - thr, btst - thr):
            report.write("\nWARNING -> From: {}-{}-{} / To: {} / Back: {}".format(rtst, gtst, btst, colYCbCr, colRGB))
            nberr += 1

        try:
            assert nberr <= maxerr
        except AssertionError:
            break
    report.write("\n {} / {} tests : {}% passed".format(nbt, 256 ** 3, percent(nbt, 256 ** 3)))
    return nbt
Exemplo n.º 2
0
def tstRGB_CMY_CMYK_CMY_RGB():
    """ RGB to CMY to CMYK back to CMY to RGB full range test """
    report.write("\nRGB->CMY->CMYK->CMY->RGB test")
    nberr = nbt = 0
    random_pick = unit_tests.RandPickInRange(100000, 500000)
    for rtst, gtst, btst in itertools.product(range(256), range(256), range(256)):
        nbt += 1
        colCMY = cCV.RGBtoCMY(rtst, gtst, btst)
        colCMYK = cCV.CMYtoCMYK(*colCMY)
        colCMY2 = cCV.CMYKtoCMY(*colCMYK)
        colRGB = cCV.CMYtoRGB(*colCMY2)

        random_pick.increment()
        if random_pick.compare() is True:
            random_pick.restart()
            report.write("\ncase pick -> From: {}-{}-{} / To: CMY {} - CMYK {} - CMY {} / Back: {}"
                         .format(rtst, gtst, btst, colCMY, colCMYK, colCMY2, colRGB))

        if colRGB > (rtst + thr, gtst + thr, btst + thr) or colRGB < (rtst - thr, gtst - thr, btst - thr):
            report.write("\nWARNING -> From: {}-{}-{} / To: CMY {} - CMYK {} - CMY {} / Back: {}"
                         .format(rtst, gtst, btst, colCMY, colCMYK, colCMY2, colRGB))
            nberr += 1

        try:
            assert nberr <= maxerr
        except AssertionError:
            break
    report.write("\n {} / {} tests : {}% passed".format(nbt, 256 ** 3, percent(nbt, 256 ** 3)))
    return nbt
Exemplo n.º 3
0
def tstRGB_XYZ_Yxy_XYZ_RGB():
    """ RGB to XYZ to Yxy back to XYZ to RGB full range test """
    report.write("\nRGB->XYZ->Yxy->XYZ->RGB test")
    nberr = nbt = 0
    random_pick = unit_tests.RandPickInRange(100000, 500000)
    for rtst, gtst, btst in itertools.product(range(256), range(256), range(256)):
        nbt += 1
        colXYZ = cCV.RGBtoXYZ(rtst, gtst, btst)
        colYxy = cCV.XYZtoYxy(*colXYZ)
        colXYZ2 = cCV.YxytoXYZ(*colYxy)
        colRGB = cCV.XYZtoRGB(*colXYZ2)

        random_pick.increment()
        if random_pick.compare() is True:
            random_pick.restart()
            report.write("\ncase pick -> From: {}-{}-{} / To: XYZ {} - Yxy {} - XYZ {} / Back: {}"
                         .format(rtst, gtst, btst, colXYZ, colYxy, colXYZ2, colRGB))

        if colRGB > (rtst + thr, gtst + thr, btst + thr) or colRGB < (rtst - thr, gtst - thr, btst - thr):
            report.write("\nWARNING -> From: {}-{}-{} / To: XYZ {} - Yxy {} - XYZ {} / Back: {}"
                         .format(rtst, gtst, btst, colXYZ, colYxy, colXYZ2, colRGB))
            nberr += 1

        try:
            assert nberr <= maxerr
        except AssertionError:
            break
    report.write("\n {} / {} tests : {}% passed".format(nbt, 256 ** 3, percent(nbt, 256 ** 3)))
    return nbt
Exemplo n.º 4
0
def tstRGB_HWB_NCS_HWB_RGB():
    """ RGB to HWB to NCS back to HWB to RGB full range test """
    report.write("\nRGB->HWB->NCS->HWB->RGB test")
    nberr = nbt = 0
    random_pick = unit_tests.RandPickInRange(100000, 500000)
    for rtst, gtst, btst in itertools.product(range(256), range(256), range(256)):
        nbt += 1
        colHWB = cCV.RGBtoHWB(rtst, gtst, btst)
        colNCS = cCV.HUEtoNCOL(colHWB[0]), colHWB[1], colHWB[2]
        colHWB2 = cCV.NCStoHWB(*colNCS)
        colRGB = cCV.HWBtoRGB(*colHWB2)

        random_pick.increment()
        if random_pick.compare() is True:
            random_pick.restart()
            report.write("\ncase pick -> From: {}-{}-{} / To: HWB {} - NCS {} - HWB {} / Back: {}"
                         .format(rtst, gtst, btst, colHWB, colNCS, colHWB2, colRGB))

        if colRGB > (rtst + thr, gtst + thr, btst + thr) or colRGB < (rtst - thr, gtst - thr, btst - thr):
            report.write("\nWARNING -> From: {}-{}-{} / To: HWB {} - NCS {} - HWB {} / Back: {}"
                         .format(rtst, gtst, btst, colHWB, colNCS, colHWB2, colRGB))
            nberr += 1

        try:
            assert nberr <= maxerr
        except AssertionError:
            break
    report.write("\n {} / {} tests : {}% passed".format(nbt, 256 ** 3, percent(nbt, 256 ** 3)))
    return nbt