forked from caetius/LeProject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_lab_range.py
47 lines (38 loc) · 1.35 KB
/
check_lab_range.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import numpy as np
from skimage.color import rgb2lab
'''
This class checks the range of LAB values returned when running skimage conversion of RGB on your machine. If the range is different to that
seen in utils.py, then you must change this. The default values used in our code are illuminant="D65" and observer="2", as per the sk-image defaults.
'''
def get_lab_range():
print("Generating all RGB pixels")
image = np.zeros((4096,4096,3))
i = 0
j = 0
maxL = 0.;
minL = 100.;
maxA = -127.;
maxB = -127.;
minA = 128.;
minB = 128.;
for r in range(256):
for g in range(256):
for b in range(256):
image[i,j] = np.array([r/255.,b/255.,g/255.])
i+=1
if i == 4096:
i=0
j+=1
print("Image generated: ", image.shape)
lab_image = rgb2lab(image)
print("image converted: ", lab_image.shape)
maxL = max(np.amax(lab_image[:,:,0]), maxL)
minL = min(np.amin(lab_image[:,:,0]), minL)
maxA = max(np.amax(lab_image[:,:,1]), maxA)
minA = min(np.amin(lab_image[:,:,1]), minA)
maxB = max(np.amax(lab_image[:,:,2]), maxB)
minB = min(np.amin(lab_image[:,:,2]), minB)
print("Range L : ", minL, ", ", maxL)
print("Range A : ", minA, ", ", maxA)
print("Range B : ", minB, ", ", maxB)
get_lab_range()