sentinel-hub/custom-scripts

Contrast and Luminance

moussmo opened this issue · 4 comments

Hello,

In my web application, I wanted to include a slider that allows the user to control the contrast and luminosity of the images. While using Sentinel Playground, I noticed the WMS service has parameters "Gain" and "Gamma", I tried using both of them in my application but I had no results. So I searched even more online, and found this 2017 article:
https://www.sentinel-hub.com/faq/what-has-changed-2017-11-release
It says that the parameters Gamma and Gain were deprecated, and should now be defined in a custom Script.
It would be nice if you could explain to me how can I do this.
Ps: I don't want to overwrite the script that is already used for my layer, but just change contrast and luminosity.

Thank you.

For stretch take a look at this:
https://www.sentinel-hub.com/faq/how-manually-configure-stretch-images
Gain is a simple multiplier, e.g:

var gain = 2.5
return [gainB04,gainB03, gain*B02];

You will have to integrate these two in your script and then adjust factors based on what user selects on the slider.

Thank you for answer.

How about Luminance (gamma) ?

Also, this would work easily when the user is viewing the custom product they made with the custom tool (the products that are already using the EVALSCRIPT parameter)

But how about the products that are already defined in Sentinel Hub 2 (for example NDVI), do we necessarily have to overwrite their predefined script with the EVALSCRIPT parameter to adjust Gamma and Gain ?

Check these links as well for gamma :
https://www.sentinel-hub.com/faq/which-functions-can-be-used-custom-script
https://www.sentinel-hub.com/faq/how-configure-visualization-so-it-reflects-old-styles

And yes, you will have to modify predefined script for NDVI and alikes if you want to "inject" these settings.

Okay, understood. Thanks for the clarification.