Old style yellow sodium street lamps, specifically Low-Pressure Sodium (LPS) lamps, emit a very narrow spectrum dominated by the sodium D-line peak around 589 nm, which gives them their characteristic monochromatic yellow-orange color. These lamps have extremely poor color rendering because they emit light in such a narrow wavelength range, meaning they cannot accurately represent other colors.
However, for the sake of creating a "reference white" or a theoretical color profile that represents the light produced by such a lamp, we can take an approximate approach. Since LPS lamps do not have a broad spectrum, defining a "white point" is somewhat artificial but can be useful for converting colors under that specific light.
Approximate Reference White for Low-Pressure Sodium Lamp
Given that LPS lamps emit light primarily around 589 nm, we can create an approximate XYZ white point for this monochromatic light source. This is not standard practice but can serve as a theoretical exercise:
- Peak Wavelength: 589 nm
- Approximate Color Temperature: Very difficult to define due to monochromatic nature, but often perceived around 1800K-2200K.
Using the CIE 1931 color matching functions, we can calculate the corresponding XYZ values for a light source with a wavelength of 589 nm. This is a bit technical, but for a simplified approach, let's assume:
- x and y chromaticity coordinates for 589 nm light are approximately (0.483, 0.472).
These can be plugged into the formula for converting xyY to XYZ space.
Conversion Formula for (xyY) to (XYZ):
[ X = \frac{x \cdot Y}{y} ]
[ Z = \frac{(1 - x - y) \cdot Y}{y} ]
Let's choose ( Y = 100 ) to represent full luminance.
function sodium_to_xyz(Y)
local x = 0.483
local y = 0.472
local X = (x * Y) / y
local Z = ((1 - x - y) * Y) / y
return X, Y, Z
end
-- Function to convert LAB to XYZ using sodium lamp reference white
function lab_to_xyz_sodium(l, a, b)
local y = (l + 16) / 116
local x = y + a / 500
local z = y - b / 200
if y^3 > 0.008856 then y = y^3 else y = (y - 16 / 116) / 7.787 end
if x^3 > 0.008856 then x = x^3 else x = (x - 16 / 116) / 7.787 end
if z^3 > 0.008856 then z = z^3 else z = (z - 16 / 116) / 7.787 end
-- Reference white point for sodium lamp
local ref_X, ref_Y, ref_Z = sodium_to_xyz(100)
x = ref_X * x
y = ref_Y * y
z = ref_Z * z
return x, y, z
end
-- Example usage
local lab_list = {
{L = 50, A = 0, B = 0},
{L = 75, A = 20, B = -20},
{L = 25, A = -10, B = 30}
}
local function read_json_file(filename)
local fake_json_content = [[
[
{"L": 50, "A": 0, "B": 0},
{"L": 75, "A": 20, "B": -20},
{"L": 25, "A": -10, "B": 30}
]
]]
return json.decode(fake_json_content)
end
local srgb_list = batch_convert_lab_to_srgb(lab_list, lab_to_xyz_sodium)
Batch Conversion for Sodium Lamp
You can then batch convert the LAB values to sRGB using the special sodium lamp reference white:
-- Main function to batch convert LAB values to sRGB
function batch_convert_lab_to_srgb(lab_list, lab_to_xyz_func)
local srgb_list = {}
for i, lab in ipairs(lab_list) do
local l, a, b = lab.L, lab.A, lab.B
local x, y, z = lab_to_xyz_func(l, a, b)
local r, g, b = xyz_to_srgb(x, y, z)
table.insert(srgb_list, {r, g, b})
end
return srgb_list
end
-- Example usage
local lab_list = read_json_file("lab_values.json")
if lab_list then
local srgb_list = batch_convert_lab_to_srgb(lab_list, lab_to_xyz_sodium)
-- Print the results
for i, srgb in ipairs(srgb_list) do
print(string.format("sRGB (Sodium): %.4f, %.4f, %.4f", srgb[1], srgb[2], srgb[3]))
end
else
print("Failed to read the JSON file")
end
Summary
Creating a practical "white point" for Low-Pressure Sodium lamps is somewhat artificial due to their narrow spectral emission. However, for theoretical purposes and to simulate their effect in color conversions, we can use their dominant wavelength to approximate chromaticity coordinates. This approximation allows us to handle color transformations under such a unique light source, although real-world color rendering would be extremely limited due to the nature of the light.
This exercise provides an interesting insight into how different light sources can dramatically affect color perception and the challenges in defining references for non-standard illuminants like sodium lamps.