Thermal imaging palette

后端 未结 2 2070
感情败类
感情败类 2021-02-14 06:09

Since the early days of thermal imaging, infrared cameras often use a distinctive palette that runs from black through blue, magenta, orange, yellow to bright white. This palett

2条回答
  •  失恋的感觉
    2021-02-14 06:44

    These palettes are arbitrary and is mainly used to improve contrast depending of type of image you're having. The values can therefor be pure custom set.

    As IR does not capture any colors (as it is outside the color range) the returned luminance value is simply mapped to what creates best contrast, in particular in regards to edges and shapes.

    The iron palette has 5-7 key colors which are then interpolated (red can be made fine-tuning the mixing between yellow and magenta). The exact values and positions can be set any way you like, here is an example:

    var ctx = document.querySelector("canvas").getContext("2d");
    var gr = ctx.createLinearGradient(0, 0, 600, 0);
    var keys = ["white", "gold", "#c07", "#20008c", "black"];
    
    // add color stops to gradient:
    for(var i = 0, key; key = keys[i]; i++) {
      gr.addColorStop(i / (keys.length-1), key);
    }
    
    ctx.fillStyle = gr;
    ctx.fillRect(0, 0, 600, 20);

提交回复
热议问题