1
$\begingroup$

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!

$\endgroup$
  • 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$ – Henrik Schumacher Dec 11 '18 at 17:25
  • $\begingroup$ @HenrikSchumacher: I arranged as requested. Thanks for the intervention. $\endgroup$ – TeM Dec 11 '18 at 17:34
1
$\begingroup$

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:

Image[Rescale@T]

enter image description here

$\endgroup$
  • $\begingroup$ First of all thank you! In reality, I only have images of some cameras, without the respective scale, but I only know the extreme temperatures of two points. $\endgroup$ – TeM Dec 11 '18 at 18:00
  • $\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$ – Henrik Schumacher Dec 11 '18 at 18:06
  • $\begingroup$ With my camera you can get images in 'gray scale' and 'rainbow'. $\endgroup$ – TeM Dec 11 '18 at 18:20
  • $\begingroup$ @TeM Did it work out? $\endgroup$ – Henrik Schumacher Dec 17 '18 at 14:24
  • $\begingroup$ Yes thanks!! =) $\endgroup$ – TeM Dec 21 '18 at 10:20

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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