I've been searching for weeks for what Lightroom and Photoshop use to determine your image's color temperature. People have said a lot about the kelvin scale and how to white balance, but this isn't exactly what I'm looking for. I noticed that from picture to picture the starting color temperature has different amounts depending on the warmth of the image. What is it doing to determine that starting amount? Is it an average of all the LAB B-channel values, or a ratio between how many values are yellow vs. blue? If it's all from the camera and the RAW file, then what is the camera doing to determine its color temperature values? I'm hoping to start programming a photo editing software and maybe one day a camera app so I'd like to know the math of how the computer makes its decisions regarding color temperature.
EDIT: I feel like I understand now. I took a digital painting into Lightroom that had no WB initially set and LR did not assign a value. I concluded that WB values must only come from what cameras set into the metadata. I guess I just did not test with the correct kinds of images. Thank you for your help and consideration.– IkariJan 21, 2021 at 6:32
The basic answer is "it depends" on what settings are selected in LR/PS (Lightroom/Photoshop).
Most of the time it is based on in-camera processes that set the color channel multipliers in the EXIF info but raw conversion applications, including LR and PS that both use ACR (Adobe Camera Raw) under the hood, can be set to use other things instead. That can be as varied as letting ACR apply its own "Auto WB" computations to using a manually selected WB (White Balance) using the Adobe application to a saved "Custom WB" created using the Adobe application(s).
How each camera does it can vary significantly from one model to the next. Even with the same camera, WB settings can be altered. Results will be different between 'Auto', a 'Preset' such as "cloudy" or "fluorescent", manually set WB, or a custom WB. Even when WB is set manually, the camera usually still does an assessment of the captured image data and saves the "automatic WB" computation in the EXIF info as well as the manually selected WB that is applied to the JPEG preview image.
There's also no guarantee that ACR/LR/PS will recognize the in-camera WB settings and use them. Particularly with "Picture Styles" (Canon), "Picture Controls" (Nikon), or any other similar name used by other camera makers, Adobe will often ignore them. Ditto with Custom White Balance set in the camera.
Please also see this rather extensive answer to What *exactly* is white balance?
This question isn't answerable, in my opinion. You are asking how a software developer designed their software.