Solved How to calculate RGB values to simulate a specific color temperature?


spapakons

Well-known member
Guru
VIP
Local time
5:03 AM
Posts
8,117
Location
Athens
OS
Windows 11 Pro 23H2 (5699), 25H2 (8655)
Hello!

Assuming I have a film camera and I want to take pictures of my monitor. Films are rated either as daylight (5500K or 6500K) or as tungsten (3200K or 3400K). In order to get the more accurate colors I have to match the color temperature of the monitor to the color temperature of the specific film type. However most monitors don't have values such as 3400K or 5500K, they only have values such as 6500K or 3200K. So I would like to know if I can simulate a specific color temperature by adjusting the R,G,B values from the monitor controls or from software such as nVidia Control Panel, Desktop color section. I guess I can, but I have no idea what values I must set to simulate a specific color temperature. Is there a formula or something to calculate it? Even better, is there a utility to choose the desired color temperature and set the values automatically, or at least tell me what they are?

Thanks a lot.

PS: Please don't suggest to use a digital camera! I am just curious how I would do it with a traditional film camera.
 
Windows Build/Version
Windows 11 Pro 25H2, last nVidia drivers

My Computers My Computers

  • At a glance

    Windows 11 Pro 23H2 (5699), 25H2 (8655)Mobile DualCore Intel Core 2 Duo T7250, 2000 MHz4GBMobile Intel(R) GMA 4500M (Mobile 4 series)
    OS
    Windows 11 Pro 23H2 (5699), 25H2 (8655)
    Computer type
    Laptop
    Manufacturer/Model
    Acer Extensa 5630EZ
    CPU
    Mobile DualCore Intel Core 2 Duo T7250, 2000 MHz
    Motherboard
    Acer Extensa 5630
    Memory
    4GB
    Graphics Card(s)
    Mobile Intel(R) GMA 4500M (Mobile 4 series)
    Sound Card
    Realtek ALC268 @ Intel 82801IB ICH9 - High Definition Audio Controller
    Monitor(s) Displays
    1
    Screen Resolution
    1280x800
    Hard Drives
    Samsung SSD 850 EVO 250GB SATA Device (250 GB, SATA-III)
    Internet Speed
    VDSL 50 Mbps
    Browser
    MICROSOFT EDGE
    Antivirus
    WINDOWS DEFENDER
    Other Info
    Legacy MBR installation, no TPM, no Secure Boot, no WDDM 2.0 graphics drivers, no SSE4.2, cannot get more unsupported ;) This is only my test laptop. I had installed Windows 11 here before upgrading my main PC. For my main PC I use everyday see my 2nd system specs.
  • At a glance

    Windows 11 Pro v25H2 (build 26200.8655)Intel Core-i7 3770 3.40GHz s1155 (3rd generat...2x Kingston Hyper-X Blu 8GB DDR3-1600GIGABYTE GeForce RTX 3050 WINDFORCE OC V2 6GB...
    Operating System
    Windows 11 Pro v25H2 (build 26200.8655)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Custom-built PC
    CPU
    Intel Core-i7 3770 3.40GHz s1155 (3rd generation)
    Motherboard
    Asus P8H61 s1155 ATX
    Memory
    2x Kingston Hyper-X Blu 8GB DDR3-1600
    Graphics card(s)
    GIGABYTE GeForce RTX 3050 WINDFORCE OC V2 6GB (GV-N3050WF2OCV2-6GD)
    Sound Card
    Realtek HD audio (ALC887)
    Monitor(s) Displays
    Sony Bravia KDL-19L4000 19" LCD TV via VGA
    Screen Resolution
    1440x900 32-bit 60Hz
    Hard Drives
    WD Blue SA510 2.5 1000GB SSD as system disk, Western Digital Caviar Purple 4TB SATA III (WD40PURZ) as second
    PSU
    Thermaltake Litepower RGB 550W Full Wired
    Case
    SUPERCASE MIDI-TOWER
    Cooling
    Deepcool Gamma Archer CPU cooler, 1x 8cm fan at the back
    Keyboard
    Mitsumi 101-key PS/2
    Mouse
    Sunnyline OptiEye PS/2
    Internet Speed
    100Mbps
    Browser
    Microsoft Edge, Mozilla Firefox
    Antivirus
    Microsoft Windows Defender
    Other Info
    Legacy BIOS (MBR) installation, no TPM, no Secure Boot, WDDM 3.0 graphics drivers, WEI score 7.4
There are a couple of applications that can do it with decent results
f.lux
redshift

For the best results you would want a colorimeter and use something like DisplayCAL
 

My Computer My Computer

At a glance

Linux Mint
OS
Linux Mint
Computer type
Laptop
Manufacturer/Model
System76 Lemur Pro
  • Like
Reactions: Gas
Last edited:

My Computers My Computers

  • At a glance

    W10Ryzen3-2200G16 GB Kingston HyperX DDR4Integrated
    OS
    W10
    Computer type
    PC/Desktop
    Manufacturer/Model
    Home brew
    CPU
    Ryzen3-2200G
    Motherboard
    GA-A320M-S2H
    Memory
    16 GB Kingston HyperX DDR4
    Graphics Card(s)
    Integrated
    Sound Card
    Integrated
    Monitor(s) Displays
    LG W2246
    Screen Resolution
    1920x1080
    Hard Drives
    Intel 760p 256GB NVMe M.2
    Seagate Barracuda 7200 1TB
    Gash Seagate ST31608
    PSU
    2006-vintage no-name
    Case
    Acer Aspire 2006
    Cooling
    Air (fan-assist)
    Keyboard
    HP SK-2885
    Mouse
    wireless
    Internet Speed
    32 mbps
    Browser
    FF latest
    Antivirus
    MS Defender
  • At a glance

    W10Ryzen 5 3500U8 GBon-board
    Operating System
    W10
    Computer type
    Laptop
    Manufacturer/Model
    HP 255 G8
    CPU
    Ryzen 5 3500U
    Memory
    8 GB
    Graphics card(s)
    on-board
    Monitor(s) Displays
    16"
    Screen Resolution
    1920x1080
    Hard Drives
    Samsung SSD 512GB Nvme
    Browser
    FF + Edge
    Antivirus
    MS Defender
Wow! Thanks. I just need to simple Maths to convert 255 max to 100 max (we call it Method of three in Greek) and set the values in the monitor. Alternatively I can set them in nVidia Control Panel.
 

My Computers My Computers

  • At a glance

    Windows 11 Pro 23H2 (5699), 25H2 (8655)Mobile DualCore Intel Core 2 Duo T7250, 2000 MHz4GBMobile Intel(R) GMA 4500M (Mobile 4 series)
    OS
    Windows 11 Pro 23H2 (5699), 25H2 (8655)
    Computer type
    Laptop
    Manufacturer/Model
    Acer Extensa 5630EZ
    CPU
    Mobile DualCore Intel Core 2 Duo T7250, 2000 MHz
    Motherboard
    Acer Extensa 5630
    Memory
    4GB
    Graphics Card(s)
    Mobile Intel(R) GMA 4500M (Mobile 4 series)
    Sound Card
    Realtek ALC268 @ Intel 82801IB ICH9 - High Definition Audio Controller
    Monitor(s) Displays
    1
    Screen Resolution
    1280x800
    Hard Drives
    Samsung SSD 850 EVO 250GB SATA Device (250 GB, SATA-III)
    Internet Speed
    VDSL 50 Mbps
    Browser
    MICROSOFT EDGE
    Antivirus
    WINDOWS DEFENDER
    Other Info
    Legacy MBR installation, no TPM, no Secure Boot, no WDDM 2.0 graphics drivers, no SSE4.2, cannot get more unsupported ;) This is only my test laptop. I had installed Windows 11 here before upgrading my main PC. For my main PC I use everyday see my 2nd system specs.
  • At a glance

    Windows 11 Pro v25H2 (build 26200.8655)Intel Core-i7 3770 3.40GHz s1155 (3rd generat...2x Kingston Hyper-X Blu 8GB DDR3-1600GIGABYTE GeForce RTX 3050 WINDFORCE OC V2 6GB...
    Operating System
    Windows 11 Pro v25H2 (build 26200.8655)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Custom-built PC
    CPU
    Intel Core-i7 3770 3.40GHz s1155 (3rd generation)
    Motherboard
    Asus P8H61 s1155 ATX
    Memory
    2x Kingston Hyper-X Blu 8GB DDR3-1600
    Graphics card(s)
    GIGABYTE GeForce RTX 3050 WINDFORCE OC V2 6GB (GV-N3050WF2OCV2-6GD)
    Sound Card
    Realtek HD audio (ALC887)
    Monitor(s) Displays
    Sony Bravia KDL-19L4000 19" LCD TV via VGA
    Screen Resolution
    1440x900 32-bit 60Hz
    Hard Drives
    WD Blue SA510 2.5 1000GB SSD as system disk, Western Digital Caviar Purple 4TB SATA III (WD40PURZ) as second
    PSU
    Thermaltake Litepower RGB 550W Full Wired
    Case
    SUPERCASE MIDI-TOWER
    Cooling
    Deepcool Gamma Archer CPU cooler, 1x 8cm fan at the back
    Keyboard
    Mitsumi 101-key PS/2
    Mouse
    Sunnyline OptiEye PS/2
    Internet Speed
    100Mbps
    Browser
    Microsoft Edge, Mozilla Firefox
    Antivirus
    Microsoft Windows Defender
    Other Info
    Legacy BIOS (MBR) installation, no TPM, no Secure Boot, WDDM 3.0 graphics drivers, WEI score 7.4
This batch script generates two sets of RGB numbers, one using Andreas Siess' lookup table and one using the Tanner Helland's algorithm. Because the lookup table only runs from 1000K - 12000K, the script is limited to that range.

Code:
C:\Users\GARLIN\Downloads>ColorTemp.bat 5000
5000K        Tanner H        Andreas S
          R: 255  100%    R: 255  100%
          G: 228   89%    G: 228   89%
          B: 206   81%    B: 206   81%

C:\Users\GARLIN\Downloads>ColorTemp.bat 12000
12000K       Tanner H        Andreas S
          R: 191   75%    R: 195   76%
          G: 211   83%    G: 209   82%
          B: 255  100%    B: 255  100%

C:\Users\GARLIN\Downloads>ColorTemp.bat 15000
Temperature range must be between 1000K - 12000K
 

Attachments

My Computer My Computer

At a glance

Windows 7
OS
Windows 7
This batch script...
Please tell me you didn't knock this up after the question was posed? You had it up your sleeve already, I hope? I was in the process of creating my own little script to use the values in the tables (for my own amusment), but now I may give up... Martin
 

My Computers My Computers

  • At a glance

    W10Ryzen3-2200G16 GB Kingston HyperX DDR4Integrated
    OS
    W10
    Computer type
    PC/Desktop
    Manufacturer/Model
    Home brew
    CPU
    Ryzen3-2200G
    Motherboard
    GA-A320M-S2H
    Memory
    16 GB Kingston HyperX DDR4
    Graphics Card(s)
    Integrated
    Sound Card
    Integrated
    Monitor(s) Displays
    LG W2246
    Screen Resolution
    1920x1080
    Hard Drives
    Intel 760p 256GB NVMe M.2
    Seagate Barracuda 7200 1TB
    Gash Seagate ST31608
    PSU
    2006-vintage no-name
    Case
    Acer Aspire 2006
    Cooling
    Air (fan-assist)
    Keyboard
    HP SK-2885
    Mouse
    wireless
    Internet Speed
    32 mbps
    Browser
    FF latest
    Antivirus
    MS Defender
  • At a glance

    W10Ryzen 5 3500U8 GBon-board
    Operating System
    W10
    Computer type
    Laptop
    Manufacturer/Model
    HP 255 G8
    CPU
    Ryzen 5 3500U
    Memory
    8 GB
    Graphics card(s)
    on-board
    Monitor(s) Displays
    16"
    Screen Resolution
    1920x1080
    Hard Drives
    Samsung SSD 512GB Nvme
    Browser
    FF + Edge
    Antivirus
    MS Defender
I don't plan to use any script. My programming skills stop at GW-Basic (or Q-Basic), very little Pascal before University and very little C at University. Now 30 years later, I barely remember my GW-Basic... I will just use the values from the table to change a photo's or video's colors to simulate the desired color temperature. Thanks.
 

My Computers My Computers

  • At a glance

    Windows 11 Pro 23H2 (5699), 25H2 (8655)Mobile DualCore Intel Core 2 Duo T7250, 2000 MHz4GBMobile Intel(R) GMA 4500M (Mobile 4 series)
    OS
    Windows 11 Pro 23H2 (5699), 25H2 (8655)
    Computer type
    Laptop
    Manufacturer/Model
    Acer Extensa 5630EZ
    CPU
    Mobile DualCore Intel Core 2 Duo T7250, 2000 MHz
    Motherboard
    Acer Extensa 5630
    Memory
    4GB
    Graphics Card(s)
    Mobile Intel(R) GMA 4500M (Mobile 4 series)
    Sound Card
    Realtek ALC268 @ Intel 82801IB ICH9 - High Definition Audio Controller
    Monitor(s) Displays
    1
    Screen Resolution
    1280x800
    Hard Drives
    Samsung SSD 850 EVO 250GB SATA Device (250 GB, SATA-III)
    Internet Speed
    VDSL 50 Mbps
    Browser
    MICROSOFT EDGE
    Antivirus
    WINDOWS DEFENDER
    Other Info
    Legacy MBR installation, no TPM, no Secure Boot, no WDDM 2.0 graphics drivers, no SSE4.2, cannot get more unsupported ;) This is only my test laptop. I had installed Windows 11 here before upgrading my main PC. For my main PC I use everyday see my 2nd system specs.
  • At a glance

    Windows 11 Pro v25H2 (build 26200.8655)Intel Core-i7 3770 3.40GHz s1155 (3rd generat...2x Kingston Hyper-X Blu 8GB DDR3-1600GIGABYTE GeForce RTX 3050 WINDFORCE OC V2 6GB...
    Operating System
    Windows 11 Pro v25H2 (build 26200.8655)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Custom-built PC
    CPU
    Intel Core-i7 3770 3.40GHz s1155 (3rd generation)
    Motherboard
    Asus P8H61 s1155 ATX
    Memory
    2x Kingston Hyper-X Blu 8GB DDR3-1600
    Graphics card(s)
    GIGABYTE GeForce RTX 3050 WINDFORCE OC V2 6GB (GV-N3050WF2OCV2-6GD)
    Sound Card
    Realtek HD audio (ALC887)
    Monitor(s) Displays
    Sony Bravia KDL-19L4000 19" LCD TV via VGA
    Screen Resolution
    1440x900 32-bit 60Hz
    Hard Drives
    WD Blue SA510 2.5 1000GB SSD as system disk, Western Digital Caviar Purple 4TB SATA III (WD40PURZ) as second
    PSU
    Thermaltake Litepower RGB 550W Full Wired
    Case
    SUPERCASE MIDI-TOWER
    Cooling
    Deepcool Gamma Archer CPU cooler, 1x 8cm fan at the back
    Keyboard
    Mitsumi 101-key PS/2
    Mouse
    Sunnyline OptiEye PS/2
    Internet Speed
    100Mbps
    Browser
    Microsoft Edge, Mozilla Firefox
    Antivirus
    Microsoft Windows Defender
    Other Info
    Legacy BIOS (MBR) installation, no TPM, no Secure Boot, WDDM 3.0 graphics drivers, WEI score 7.4
Please tell me you didn't knock this up after the question was posed? You had it up your sleeve already, I hope? I was in the process of creating my own little script to use the values in the tables (for my own amusment), but now I may give up... Martin
I just adapted the presented code from Tanner's article. His code example can be readily translated into any high-level programming or scripting language by fixing the if-then constructs, and the syntax for variables. The article notes how many other folks have translated it into their favorite languages,

Andreas' table of lookup values can be rewritten as a PowerShell array of arrays, using two global search & replace edits. I lucked out there in not having to do much work.

There's no reason not to convert it yourself, as a learning exercise. At least you have another script to confirm the output results are the same. It probably took me less time simply because in my previous line of work, I've had to convert random code examples to other languages.
 

My Computer My Computer

At a glance

Windows 7
OS
Windows 7
I don't plan to use any script.
Speaking on behalf of the author, you only have to run the batch file, passing the colour temperature you want. The programming has been done.
 

My Computers My Computers

  • At a glance

    W10Ryzen3-2200G16 GB Kingston HyperX DDR4Integrated
    OS
    W10
    Computer type
    PC/Desktop
    Manufacturer/Model
    Home brew
    CPU
    Ryzen3-2200G
    Motherboard
    GA-A320M-S2H
    Memory
    16 GB Kingston HyperX DDR4
    Graphics Card(s)
    Integrated
    Sound Card
    Integrated
    Monitor(s) Displays
    LG W2246
    Screen Resolution
    1920x1080
    Hard Drives
    Intel 760p 256GB NVMe M.2
    Seagate Barracuda 7200 1TB
    Gash Seagate ST31608
    PSU
    2006-vintage no-name
    Case
    Acer Aspire 2006
    Cooling
    Air (fan-assist)
    Keyboard
    HP SK-2885
    Mouse
    wireless
    Internet Speed
    32 mbps
    Browser
    FF latest
    Antivirus
    MS Defender
  • At a glance

    W10Ryzen 5 3500U8 GBon-board
    Operating System
    W10
    Computer type
    Laptop
    Manufacturer/Model
    HP 255 G8
    CPU
    Ryzen 5 3500U
    Memory
    8 GB
    Graphics card(s)
    on-board
    Monitor(s) Displays
    16"
    Screen Resolution
    1920x1080
    Hard Drives
    Samsung SSD 512GB Nvme
    Browser
    FF + Edge
    Antivirus
    MS Defender
It's there for anyone who's looking for a simple tool and isn't a coder. I found it interesting that one approach presents a table without much explanation about how it's calibrated (except to hint at another source), and the other dev explains his approximation method.

But without a colorimeter, you're supposed to run a LCD monitor calibration test by adjusting brightness, etc. Otherwise all this data is irrelevant if your monitor isn't somewhat calibrated, and doesn't have its native ICC color profile loaded.
 

My Computer My Computer

At a glance

Windows 7
OS
Windows 7
I just adapted the presented code from Tanner's article.
When I wrote my comment, I had copied the data table from Mitchell Charity’s web page, and used Excel to come up with curve fits - which not surprisingly produced the same (almost) coefficients for blue - I stopped there, as I was re-inventing the wheel, and not adding anything. If your batch file didn't work so easily, I would probably have coded it in vbs for simplicity.

But I was intrigued by your method of embedding the code in powershell, inside a batch file. I now know had seen that before a couple of years ago on TenForums, but forgotten about it. But I didn't note who posted the code back then, only the date - so I plugged 'timestamps' into the tenforum search window, and, hey presto, first up came the very thread, dated 22/12/23 - and guess who supplied the code? You probably already know it was you!

I had better think about using that method next time... Thanks, Martin
 

My Computers My Computers

  • At a glance

    W10Ryzen3-2200G16 GB Kingston HyperX DDR4Integrated
    OS
    W10
    Computer type
    PC/Desktop
    Manufacturer/Model
    Home brew
    CPU
    Ryzen3-2200G
    Motherboard
    GA-A320M-S2H
    Memory
    16 GB Kingston HyperX DDR4
    Graphics Card(s)
    Integrated
    Sound Card
    Integrated
    Monitor(s) Displays
    LG W2246
    Screen Resolution
    1920x1080
    Hard Drives
    Intel 760p 256GB NVMe M.2
    Seagate Barracuda 7200 1TB
    Gash Seagate ST31608
    PSU
    2006-vintage no-name
    Case
    Acer Aspire 2006
    Cooling
    Air (fan-assist)
    Keyboard
    HP SK-2885
    Mouse
    wireless
    Internet Speed
    32 mbps
    Browser
    FF latest
    Antivirus
    MS Defender
  • At a glance

    W10Ryzen 5 3500U8 GBon-board
    Operating System
    W10
    Computer type
    Laptop
    Manufacturer/Model
    HP 255 G8
    CPU
    Ryzen 5 3500U
    Memory
    8 GB
    Graphics card(s)
    on-board
    Monitor(s) Displays
    16"
    Screen Resolution
    1920x1080
    Hard Drives
    Samsung SSD 512GB Nvme
    Browser
    FF + Edge
    Antivirus
    MS Defender
Back
Top Bottom