Pixel false color map implementation using SkiaSharp

60 Views Asked by At

In my application the image data comes from a scientific camera in the form of 32-bit floating point numbers per pixel. This pixel value is proportional to the light intensity, there is no color information. I would like to map pixel intensities according to a specific colormap and display it using SKCanvas.DrawBitmap().

So far my method is as follows:

  1. Convert input 32-bit float image into BGRA8888 image by linearly converting values from float to grayscale 0...255, where lowest pixel value in float image corresponds to 0,0,0, and maximum pixel value corresponds to 0xFF,0xFF,0xFF (ignore the alpha channel).
  2. Apply table-based filter using SKColorFilter.CreateTable() which remaps the grayscale data into the desired colormap.

The problem with this approach is that sometimes I would like to clip the image data (e.g. if there was a minimum pixel value of -123.6, but we want to view all pixels below -100.0 as 0,0,0. This requires recalculating the image data in the step (1). Is there a more neat way to implement the transformation float32 -> colorfilter table?

I am relatively new to Skia and SkiaSharp, I would appreciate if someone forwards me to the right topic/direction. Thank you.

P.S. I am using Avalonia UI and its ICustomDrawOperation as in their samples example, but I guess it does not really matter.

0

There are 0 best solutions below