Пример #1
0
def filterR4Crisp(img, k, tc, mu, beta, img_A=None, img_B=None, img_C=None):
    """ Apply filter R4-Crsip on img given pre-computed tc, mu and beta """
    l = len(img)
    result = np.zeros((l, l))

    if img_A is None:
        img_A = filterA(img, k, mu, beta)

    if img_B is None:
        img_B = filterB(img, k, beta)

    if img_C is None:
        img_C = filterC(img, k, mu, beta)

    for i in range(l):
        for j in range(l):
            c1 = small(tc[i][j])
            c2 = medium(tc[i][j])
            c3 = large(tc[i][j])
            if c1 == max(c1, c2, c3):
                result[i][j] = img_B[i][j]
            elif c2 == max(c1, c2, c3):
                result[i][j] = img_A[i][j]
            else:
                result[i][j] = img_C[i][j]

    return result
Пример #2
0
def plot(tc, imagepath):
    l = len(tc)
    sm_img = np.zeros((l, l))
    med_img = np.zeros((l, l))
    large_img = np.zeros((l, l))

    for i in range(l):
        for j in range(l):
            sm_img[i][j] = small(tc[i][j])
            med_img[i][j] = medium(tc[i][j])
            large_img[i][j] = large(tc[i][j])

    op_imagepath = os.path.join(
        'images', 'tc',
        os.path.basename(imagepath)[:-4] + '_Small.png')
    normalize_and_save(op_imagepath, sm_img)

    op_imagepath = os.path.join(
        'images', 'tc',
        os.path.basename(imagepath)[:-4] + '_Medium.png')
    normalize_and_save(op_imagepath, med_img)

    op_imagepath = os.path.join(
        'images', 'tc',
        os.path.basename(imagepath)[:-4] + '_Large.png')
    normalize_and_save(op_imagepath, large_img)
Пример #3
0
def filterR4(img, k, tc, mu, beta, img_A=None, img_B=None, img_C=None):
    """ Apply filter R4 on img given pre-computed tc, mu and beta """
    l = len(img)
    result = np.zeros((l, l))

    if img_A is None:
        img_A = filterA(img, k, mu, beta)

    if img_B is None:
        img_B = filterB(img, k, beta)

    if img_C is None:
        img_C = filterC(img, k, mu, beta)

    for i in range(l):
        for j in range(l):
            c1 = small(tc[i][j])
            c2 = medium(tc[i][j])
            c3 = large(tc[i][j])
            result[i][j] = (c1 * img_B[i][j] + c2 * img_A[i]
                            [j] + c3 * img_C[i][j]) / (c1 + c2 + c3)

    return result