Hello image analysis people,

I was thinking about this recently: hypothetically, if I have a gray scale image and I apply a LUT and convert the "LUTed" image to RGB and save it; what is the fastest way to make a "reverse lookup" (I don't even know if this term exist)?

Let's make the following assumptions:

1) each LUT assigned value is unique in the LUT set (each original intensity produces a unique RGB value)

2) the image is saved in a loss less format

3) the original image was an 8-bit gray scale image

I was thinking about doing something like this but I don't know if that is an efficient way:

In order to get the LUT values I would produce a 1 x 256 pixel wide image with a linear gradient from 0 to 255. Then I would apply the LUT and convert it into RGB. Then in a loop I would fill an array with the assigned pixel values - the position in the array would correspond to the original intensity value. Alternatively the lookup tables are available, then I don't need to do this.

then I would open the RGB image I want to reverse lookup. I would make a loop through all the 256 entries of the array and perform something like a "replace color" with the original intensity - I guess doing it pixelwise is super brute force.

I haven't tried the procedure yet, I guess it should work but I assume that there must be some shortcuts. I mean, probably there is a way to make the loop more specific - loop only values that are present?! I mean a loop with 256 repeats may be ok, but what if the initial image was a 32-bit gray scale image? I guess my computer would start to melt... :-)

Any advice or hints how I should proceed or where I'm thinking in a wrong direction?

ps. I attached an example, it is useless, however, since I saved it in a heavily compressed jpeg. Maybe in this example there is a function f(original)=LUT but let's assume the LUT is no gradient gives me non-related but unque values.

More Martin Jakob's questions See All
Similar questions and discussions