Exemplo n.º 1
0
def HSVStretching(sceneRadiance):
    height = len(sceneRadiance)
    width = len(sceneRadiance[0])
    img_hsv = rgb2hsv(sceneRadiance)
    h, s, v = cv2.split(img_hsv)
    img_s_stretching = global_stretching(s, height, width)
    # print('np.min(img_s_stretching)',np.min(img_s_stretching))
    # print('np.max(img_s_stretching)',np.max(img_s_stretching))
    # print('np.mean(img_s_stretching)',np.mean(img_s_stretching))

    img_v_stretching = global_stretching(v, height, width)

    # print('np.min(img_v_stretching)', np.min(img_v_stretching))
    # print('np.max(img_v_stretching)', np.max(img_v_stretching))
    # print('np.mean(img_v_stretching)', np.mean(img_v_stretching))

    # img_L_sHretching = global_Stretching.global_stretching(L, height, width)
    # img_a_stretching = global_stretching_ab.global_Stretching_ab(a, height, width)
    # img_b_stretching = global_stretching_ab.global_Stretching_ab(b, height, width)

    labArray = np.zeros((height, width, 3), 'float64')
    labArray[:, :, 0] = h
    labArray[:, :, 1] = img_s_stretching
    labArray[:, :, 2] = img_v_stretching
    img_rgb = hsv2rgb(labArray) * 255

    # img_rgb = np.clip(img_rgb, 0, 255)

    return img_rgb
def HSVStretching(sceneRadiance):
    sceneRadiance = np.uint8(sceneRadiance)
    height = len(sceneRadiance)
    width = len(sceneRadiance[0])
    img_hsv = rgb2hsv(sceneRadiance)
    h, s, v = cv2.split(img_hsv)
    img_s_stretching = global_stretching(s, height, width)
    img_v_stretching = global_stretching(v, height, width)

    labArray = np.zeros((height, width, 3), 'float64')
    labArray[:, :, 0] = h
    labArray[:, :, 1] = img_s_stretching
    labArray[:, :, 2] = img_v_stretching
    img_rgb = hsv2rgb(labArray) * 255

    # img_rgb = np.clip(img_rgb, 0, 255)

    return img_rgb
Exemplo n.º 3
0
files = natsort.natsorted(files)

for i in range(len(files)):
    file = files[i]
    filepath = path + "/" + file
    prefix = file.split('.')[0]
    if os.path.isfile(filepath):
        print('********    file   ********', file)
        img = cv2.imread(folder + '/InputImages/' + file)

        blockSize = 9
        gimfiltR = 50  # 引导滤波时半径的大小
        eps = 10**-3  # 引导滤波时epsilon的值

        DepthMap = depthMap(img)
        DepthMap = global_stretching(DepthMap)
        guided_filter = GuidedFilter(img, gimfiltR, eps)
        refineDR = guided_filter.filter(DepthMap)
        refineDR = np.clip(refineDR, 0, 1)

        cv2.imwrite('ULAPDepthMap.jpg', np.uint8(refineDR * 255))
        plt.subplot(311), plt.imshow(np.uint8(refineDR * 255))
        plt.show()

        AtomsphericLight = BLEstimation(img, DepthMap) * 255

        d_0 = minDepth(img, AtomsphericLight)
        d_f = 8 * (DepthMap + d_0)
        transmissionB, transmissionG, transmissionR = getRGBTransmissionESt(
            d_f)
Exemplo n.º 4
0
        AtomsphericLight = ThreeAtomsphericLightFusion(AtomsphericLightOne,
                                                       AtomsphericLightTwo,
                                                       AtomsphericLightThree,
                                                       img)
        print('AtomsphericLight', AtomsphericLight)  # [b,g,r]

        R_map = max_R(img, blockSize)
        mip_map = R_minus_GB(img, blockSize, R_map)
        bluriness_map = BlurrnessMap

        d_R = 1 - StretchingFusion(R_map)
        d_D = 1 - StretchingFusion(mip_map)
        d_B = 1 - StretchingFusion(bluriness_map)

        d_n = Scene_depth(d_R, d_D, d_B, img, AtomsphericLight)
        d_n_stretching = global_stretching(d_n)
        d_0 = closePoint(img, AtomsphericLight)
        d_f = 8 * (d_n + d_0)

        # cv2.imwrite('OutputImages/' + prefix + '_IBLADepthMapd_D.jpg', np.uint8((d_D)*255))
        # cv2.imwrite('OutputImages/' + prefix + '_IBLADepthMap.jpg', np.uint8((d_f/d_f.max())*255))

        transmissionR = getTransmission(d_f)
        transmissionB, transmissionG = getGBTransmissionESt(
            transmissionR, AtomsphericLight)
        transmissionB, transmissionG, transmissionR = Refinedtransmission(
            transmissionB, transmissionG, transmissionR, img)

        # cv2.imwrite('OutputImages/' + prefix + '_IBLA_TM.jpg', np.uint8(np.clip(transmissionR * 255, 0, 255)))

        sceneRadiance = sceneRadianceRGB(img, transmissionB, transmissionG,