How to Calculate the Color Temperature / Tint of the Colors in an Image?
This paper (pdf download) gives the following formulae for calculating Correlated Color Temperature (CCT). They do not explicitly say (or I missed it), but their example leads me to infer that they are assuming RGB values in the range of 0-255.

1. Convert the RGB values to CIE tristimulus values (XYZ) as follows:

$$X = (-0.14282)(R) + (1.54924)(G) + (-0.95641)(B)$$
$$Y = (-0.32466)(R) + (1.57837)(G) + (-0.73191)(B) = Illuminance$$
$$Z = (-0.68202)(R) + (0.77073)(G) + (0.56332)(B)$$

2. Calculate the normalized chromaticity values:

$$x = X/(X+Y+Z)$$
$$y = Y/(X+Y+Z)$$

3. Compute the CCT value from:

$$CCT = 449n^3 + 3525n^2 + 6823.3n + 5520.33$$

$$\text{where }n = (x − 0.3320) / (0.1858 − y)$$

Which can be combined to form the following equation:

$$CCT = 449n^3 + 3525n^2 + 6823.3n + 5520.33$$
$$\text{where }n = ((0.23881)R+(0.25499)G+(-0.58291)B) / ((0.11109)R+(-0.85406)G+(0.52289)B)$$

I am not sure about applying this to an image, but if you just want a single, generalizing number, than you could perhaps use some sort of averaging? Either find an acceptable "average" RGB value for the image (eg. the centroid) and use that to calculate a temperature or (a much more computationally expensive option) calculate the temperature for each pixel in the image and take the average of those results.

Also, bear in mind that CCT is only an approximate metric for most colors, since only a single curve in the color space actually represents color which can be obtained from a real world black body radiator. Thus for all other colors, the calculated color temperature is simply an approximation of the black body temperature it most closely represents. Thus, for some colors (especially greens) it can actually be a somewhat meaningless value, at least in a physical sense. This is illustrated well in the following image (from the wikipedia article on color temperature).



The black line in the image represents the Planckian Locus of colors which could actually be produced by block body radiation. The smaller crossing lines represent the isotherms of the CCT approximation nearbye.

Also, since your question specifically references Adobe Lightroom, I found this while searching around:


  The sliders [in Adobe Lightroom] adjust not the black body temp of the light, but the compensation applied to the image to compensate for the black body temp of the light.  This goes the other way round.


So bear in mind that the color temperature you see on the Lightroom slider will not be the same as those calculated from the above formulae.