Importing the following image (without a scale):

enter image description here

and knowing the extreme temperatures, is it possible to obtain the graduated scale?

Also, it would be interesting to get the temperatures of all the points by moving the cursor over the image.

Thanks a lot!

  • 1
    $\begingroup$ Does the color bar really belong to the image? It would be very helpful to have the precise color gradient that was used for that image. $\endgroup$ Dec 11, 2018 at 17:25

1 Answer 1


If the color bar posted by OP really belongs to the image then the following should provide quite a good approximation. First, I extract the color bar scale and the actual image actualimage from the plot. By hand. This can certainly be automated somehow. Next, I use Nearest to build up a lookup table nf for color values. (This will result is strange results for pixels in the image that have a color that does not appear in the color bar. But this should not happen anyway.) Finally, I apply the NearestFunction nf to each pixel in order to find the temperature value whose color value on the color bar is closest to the pixel.

img = Import["https://i.stack.imgur.com/US42T.png"];
scale = Mean /@ ImageData[img][[27 ;; -26, -90 ;; -60]];
actualimage = ImageData[img][[;; , 1 ;; -112]];
nf = Nearest[scale -> Reverse@Subdivide[-7.2, 11.0, Length[scale] - 1]];
T = ArrayReshape[nf[Flatten[actualimage, 1], 1],Dimensions[actualimage][[1 ;; 2]]];

Here is a grayscale version of the resulting temperature array T:


enter image description here

  • $\begingroup$ Hm. That's too bad. We have to interpolate between these extreme values somehow. And it is not obvious how to do that because color space is three-dimensional and a color bar can be any continuous curve in this 3-space. I would guess that the cameras should have a documentation that tells you how this should be done. Maybe the cameras are also able to return grayscale images? Grayscales would be straightforward to interpolate... $\endgroup$ Dec 11, 2018 at 18:06
  • $\begingroup$ @TeM Did it work out? $\endgroup$ Dec 17, 2018 at 14:24
  • $\begingroup$ Glad to hear that! You're welcome! $\endgroup$ Dec 21, 2018 at 10:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.