-
Notifications
You must be signed in to change notification settings - Fork 60
Basic concepts
It's just an array you use to pre-calculate results.
For an 8-bit image, there are only 256 possible values for pixels. For example, you don't need to calculate pow() for every pixel, just calculate pow() for the values 0 - 255, then when you process the image just look up the correct result in the table rather than calculating it each time.
lut = Image.identity(1)
This makes a 1 band image 256 elements across and one element deep where elements have the values 0, 1, 2, 3, 4, 5, ... 255. It's called "identity" because it creates an identity function.
lut = lut.pow(0.5).lin(255 / 255 ** 0.5, 0)
This runs the pow() on the identity LUT. So element 123 (for example) will contain
123 ** 0.5 * 255 / 255 ** 0.5
ie. the result that every pixel with the value 123 out to be changed to.
Finally this:
im = im.maplut(lut)
loops over the large image looking up every pixel value in lut and replacing it with the pre-calculated result.