-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
31 lines (25 loc) · 975 Bytes
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import glob
import numpy as np
from scipy.io import loadmat
def get_images_fullpath(img_folder_path):
""" get all the images for the specified folder
Args:
img_folder_path (str): path which contains the images
img_file_format (str): image file format
Returns:
images_fullpath (list): list of image (full) paths
"""
images_fullpath = glob.glob(img_folder_path + "**/*.png", recursive=True)
images_fullpath.sort(key=lambda x: x.split('/')[-1].split('.')[0])
return images_fullpath
def load_groundtruth_illuminant(file_path):
""" load ground truth illuminant
Args:
file_path (str): path which contains the ground truth illuminant values
Returns:
real_rgb (np.array): ground truth illuminant values
"""
real_illum_568 = loadmat(file_path)
real_rgb = real_illum_568["real_rgb"]
real_rgb = real_rgb / real_rgb[:, 1][:, np.newaxis] # convert to chromaticity
return real_rgb