kylebarron / deck.gl-raster

deck.gl layers and WebGL modules for client-side satellite imagery analysis
https://kylebarron.dev/deck.gl-raster/
MIT License
85 stars 10 forks source link

Port rio-color operations #17

Open kylebarron opened 4 years ago

kylebarron commented 4 years ago

Gamma adjustment adjusts RGB values according to a power law, effectively brightening or darkening the midtones. It can be very effective in satellite imagery for reducing atmospheric haze in the blue and green bands.

Sigmoidal contrast adjustment can alter the contrast and brightness of an image in a way that matches human's non-linear visual perception. It works well to increase contrast without blowing out the very dark shadows or already-bright parts of the image.

Saturation can be thought of as the "colorfulness" of a pixel. Highly saturated colors are intense and almost cartoon-like, low saturation is more muted, closer to black and white. You can adjust saturation independently of brightness and hue but the data must be transformed into a different color space.

Saturation looks like a more difficult operation, plus it already exists in luma.gl's shadertools.

But gamma and sigmoidal don't look that hard to port.

kylebarron commented 4 years ago

Note that some operations that are efficient in C aren't efficient in GLSL because of if/else branching.

Here's an example of a fast rgb2hsv and hsv2rgb optimized for the GPU (used in saturation).

kylebarron commented 4 years ago

Also ref https://github.com/tobspr/GLSL-Color-Spaces

kylebarron commented 4 years ago

https://www.chilliant.com/rgb2hsv.html