Beispiel #1
0
def augment(img):
    np.seterr(over='ignore')

    blockSize = 9
    height = len(img)
    width = len(img[0])
    gimfiltR = 50  # Radius size of guided filter
    eps = 10**-3  # Epsilon value of guided filter
    Nrer = [0.95, 0.93,
            0.85]  # Normalized residual energy ratio of G-B-R channels

    AtomsphericLight = np.zeros(3)
    AtomsphericLight[0] = (
        1.13 * np.mean(img[:, :, 0])) + 1.11 * np.std(img[:, :, 0]) - 25.6
    AtomsphericLight[1] = (
        1.13 * np.mean(img[:, :, 1])) + 1.11 * np.std(img[:, :, 1]) - 25.6
    AtomsphericLight[2] = 140 / (
        1 + 14.4 * np.exp(-0.034 * np.median(img[:, :, 2])))
    AtomsphericLight = np.clip(AtomsphericLight, 5, 250)
    transmissionR = getTransmission(img, AtomsphericLight, blockSize)
    TM_R_modified = Depth_TM(img, AtomsphericLight)
    TM_R_modified_Art = Sat_max(img)
    transmissionR_new = np.copy(transmissionR)
    for i in range(0, img.shape[0]):
        for j in range(0, img.shape[1]):
            if (transmissionR_new[i, j] > TM_R_modified[i, j]):
                transmissionR_new[i, j] = TM_R_modified[i, j]
            if (transmissionR_new[i, j] < TM_R_modified_Art[i, j]):
                transmissionR_new[i, j] = TM_R_modified_Art[i, j]

    transmissionR_Stretched = stretching(transmissionR_new, height, width)
    transmissionB, transmissionG, depth_map = getGBTransmissionESt(
        transmissionR_Stretched, AtomsphericLight)
    transmission = Refinedtransmission(transmissionB, transmissionG,
                                       transmissionR_Stretched, img)
    sceneRadiance = sceneRadianceRGB(img, transmission, AtomsphericLight)
    sceneRadiance = OptimalParameter(sceneRadiance)

    return sceneRadiance
Beispiel #2
0
        transmissionR = getTransmission(img, AtomsphericLight, blockSize)
        TM_R_modified = Depth_TM(img, AtomsphericLight)
        TM_R_modified_Art = Sat_max(img)
        transmissionR_new = np.copy(transmissionR)
        # for i in range(0, img.shape[0]):
        #     for j in range(0, img.shape[1]):
        #         if (transmissionR_new[i, j] > TM_R_modified[i, j]):
        #             transmissionR_new[i, j] = TM_R_modified[i, j]
        for i in range(0, img.shape[0]):
            for j in range(0, img.shape[1]):
                if (transmissionR_new[i, j] > TM_R_modified[i, j]):
                    transmissionR_new[i, j] = TM_R_modified[i, j]
                if (transmissionR_new[i, j] < TM_R_modified_Art[i, j]):
                    transmissionR_new[i, j] = TM_R_modified_Art[i, j]

        transmissionR_Stretched = stretching(transmissionR_new, height, width)
        transmissionB, transmissionG, depth_map = getGBTransmissionESt(
            transmissionR_Stretched, AtomsphericLight)
        transmission = Refinedtransmission(transmissionB, transmissionG,
                                           transmissionR_Stretched, img)
        transmissionR_Stretched = transmission[:, :, 2]

        # cv2.imwrite('Results_TMs/' + Num + 'TM_R.jpg', np.uint8(transmissionR  * 255))
        # cv2.imwrite('Results_temps/' + prefix + 'TM_R_Refi_fusion_Sat_lamba.jpg', np.uint8(transmissionR_Stretched  * 255))
        # cv2.imwrite('OutputImages/' + prefix + '_SMBLOTMOP_TM.jpg', np.uint8(transmissionR_Stretched  * 255))
        cv2.imwrite('Results_Enhance_fusion/' + prefix + '_SMBLOTMOP_TM_R.jpg',
                    np.uint8(transmissionR_Stretched * 255))
        # cv2.imwrite('Results_Enhance_fusion/' + prefix + '_SMBLOTMOP_TM_G.jpg', np.uint8(transmission[:, :, 1]  * 255))
        # cv2.imwrite('Results_Enhance_fusion/' + prefix + '_SMBLOTMOP_TM_B.jpg', np.uint8(transmission[:, :, 0]  * 255))

        sceneRadiance = sceneRadianceRGB(img, transmission, AtomsphericLight)
Beispiel #3
0
np.seterr(over='ignore')
if __name__ == '__main__':
    pass

# folder = "C:/Users/Administrator/Desktop/UnderwaterImageEnhancement/NonPhysical/ICM"
folder = r"\\cylog.local\rede\Usuarios\Documentos\Luiz\Documents\PROJETO_DIP"

path = folder + "/InputImages"
files = os.listdir(path)
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('InputImages/' + file)
        img = cv2.imread(folder + '/InputImages/' + file)
        img = stretching(img)
        sceneRadiance = sceneRadianceRGB(img)
        # cv2.imwrite(folder + '/OutputImages/' + Number + 'Stretched.jpg', sceneRadiance)
        sceneRadiance = HSVStretching(sceneRadiance)
        sceneRadiance = sceneRadianceRGB(sceneRadiance)
        cv2.imwrite('ICM.jpg', sceneRadiance)
        
        plt.subplot(111),plt.imshow(sceneRadiance)
        plt.show()
        
Beispiel #4
0
np.seterr(over='ignore')
if __name__ == '__main__':
    pass

# folder = "C:/Users/Administrator/Desktop/UnderwaterImageEnhancement/NonPhysical/UCM"
folder = "C:/Users/Administrator/Desktop/Databases/Dataset"

path = folder + "/InputImages"
files = os.listdir(path)
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('InputImages/' + file)
        img = cv2.imread(folder + '/InputImages/' + file)
        # print('Number',Number)
        sceneRadiance = RGB_equalisation(img)
        sceneRadiance = stretching(sceneRadiance)
        # # cv2.imwrite(folder + '/OutputImages/' + Number + 'Stretched.jpg', sceneRadiance)
        sceneRadiance = HSVStretching(sceneRadiance)
        sceneRadiance = sceneRadianceRGB(sceneRadiance)
        cv2.imwrite('OutputImages/' + prefix + '_UCM.jpg', sceneRadiance)

endtime = datetime.datetime.now()
time = endtime - starttime
print('time', time)