简体   繁体   English

16 位灰度图像到热图

[英]16bit greyscale image to heatmap

I'm working on a scientific imaging software for my university, and I've encountered a major problem.我正在为我的大学开发科学成像软件,但遇到了一个大问题。 Scientific camera (Apogee Alta U57) at my lab provides images as 16bpp array - it's 0-65535 values per pixel!我实验室的科学相机 (Apogee Alta U57) 以 16bpp 阵列的形式提供图像 - 每像素 0-65535 值! We want to keep this range, but in fact we can't display them on monitor (0-255 grayscale range).我们想保持这个范围,但实际上我们无法在监视器上显示它们(0-255 灰度范围)。 So I found a way to resolve this problem - simply to make use of colors, and to display whole image as a heatmap (from black, blue, through green and red, to pure white).所以我找到了解决这个问题的方法——简单地利用颜色,并将整个图像显示为热图(从黑色、蓝色、绿色和红色到纯白色)。

I mean something like this - Example heatmap image I want to achieve我的意思是这样的 - 我想要实现的示例热图图像在此处输入图片说明

My only question is: How to efficiently convert 16bpp array of pixel values to complete heatmap bitmap in c#?我唯一的问题是:如何在 c# 中有效地将 16bpp 像素值数组转换为完整的热图位图? Are there any libraries for doing that?有没有图书馆可以做到这一点? If not, how do I achieve that using .NET resources?如果没有,我如何使用 .NET 资源实现这一目标?

My idea was to create function that maps 65536 values into (255 R, 255G, 255B), but it's a tough job - especially without using HSV model.我的想法是创建将 65536 个值映射到 (255 R, 255G, 255B) 的函数,但这是一项艰巨的工作——尤其是在不使用 HSV 模型的情况下。

I would be much obliged for any help provided!我将非常感谢提供的任何帮助!

Your question consist of several parts:你的问题由几个部分组成:

  • reading in the 16 bit pixel data values读入 16 位像素数据值
  • mapping them to 24 bit rgb colors将它们映射到 24 位 rgb 颜色
  • writing them out to an image file将它们写入图像文件

I'll skip part one and three and give you a few ideas about part 2.我将跳过第一和第三部分,给你一些关于第二部分的想法。

It is in fact harder than it seems.事实上,它比看起来更难。 A unique mapping that doesn't lose any information is simple, in fact trivial, just a little bit shifting will do.一个不会丢失任何信息的独特映射很简单,实际上微不足道,只需稍微移动就可以了。

But you also want the result to work visually, meaning not so much is should be visually appealing but should make sense to a human eye.但是您还希望结果在视觉上起作用,这意味着不是应该在视觉上吸引人而是应该对人眼有意义。 so we need a mapping that has a credible yet large enough gradient.所以我们需要一个具有可信但足够大的梯度的映射。

For this you should experiment a little.为此,您应该尝试一下。 I suggest to make use of the LinearGradientBrush, as I show here .我建议使用 LinearGradientBrush,正如我在这里展示的那样。 Have a look at the interpolateColors function!看看interpolateColors函数! It uses only 6 colors in the example, way to few for your case!它在示例中仅使用 6 种颜色,对于您的情况来说很少!

You should pick many more;你应该选择更多; you may need to go through the color space in a spiral..您可能需要以螺旋形式穿过色彩空间。

The trick for you will be to choose both nice and enough stop colors to create a 64k large set of unique colors, best going from blueish to reddish..你的诀窍是选择漂亮和足够的停止颜色来创建 64k 大组独特的颜色,最好从蓝色到红色。

You will need to test the result for uniqueness;您需要测试结果的唯一性; in fact you may want to create a pair of Dictionary and Dictionary for the mappings..事实上,您可能希望为映射创建一对 Dictionary 和 Dictionary。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM