I have Lab dataset: val_lab_2 like that:
[[ 7.803e+01 3.100e-01 1.382e+01]
[ 6.697e+01 -7.400e+00 2.750e+01]
[ 5.631e+01 -1.804e+01 1.599e+01]
[ 6.701e+01 2.650e+00 2.913e+01]
[ 6.564e+01 1.660e+00 2.540e+01]
[ 3.537e+01 2.050e+01 3.784e+01]
[ 4.178e+01 2.251e+01 4.438e+01]
[ 6.129e+01 1.261e+01 5.934e+01]
[ 4.269e+01 5.120e+00 4.995e+01]...]
I want to change it to RGB 0-255, so I use colormath package:
import numpy as np
import pandas as pd
from colormath.color_objects import sRGBColor, XYZColor, LabColor
from colormath.color_conversions import convert_color
val_rgb_2 = []
for lab_list in val_lab_2:
lab = LabColor(*[component for component in lab_list])
rgb = convert_color(lab, sRGBColor)
rgb_list = [255*color for color in rgb.get_value_tuple()]
val_rgb_2.append(rgb_list)
val_rgb_2 = np.array(val_rgb_2)
print(val_rgb_2)
the result shows:
[[201.44003158 192.14717152 167.2643737 ]
[163.51015463 166.15931613 112.52909259]
[109.8451797 143.64817993 106.17872676]
[181.45664244 160.44644464 110.27374654]
[174.70091435 157.51328159 113.65978481]
[122.18753543 69.26114552 19.79086107]
[143.2650315 82.85139354 20.50673141]
[187.60706038 138.48640317 31.06087929]...]
However, I think it is not correct, because I have a label, first few rows shows it should be:
natural white 100% wool,blue-violet flowers,blue flowers,flowers,whole plant,peels,peels,peels...
