Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SigmoidalContrast - Imcomplete formula #3326

Closed
JanssenBrm opened this issue Dec 22, 2020 · 0 comments · Fixed by #3328
Closed

SigmoidalContrast - Imcomplete formula #3326

JanssenBrm opened this issue Dec 22, 2020 · 0 comments · Fixed by #3328
Labels

Comments

@JanssenBrm
Copy link
Contributor

Describe the bug

In the current implementation of the Geotrellis Sigmoidal contrast, the following formula is used to calculate the contrast for a given raster value (source) :

val numer = 1/(1+math.exp(beta*(alpha-u))) - 1/(1+math.exp(beta))
val denom = 1/(1+math.exp(beta*(alpha-1))) - 1/(1+math.exp(beta*alpha))
val gu = math.max(0.0, math.min(1.0, numer / denom))

When you look at the sigmoidal contrast formula that is defined by ImageMagick, we get the following equation:

( 1/(1+exp(β*(α-u))) - 1/(1+exp(β*(α)) ) / ( 1/(1+exp(β*(α-1))) - 1/(1+exp(β*α)) )

As you can see, the numer part of the original equation is missing a multiplication by alpha in its second diff term.The correct calculation of the numer part should be:

val numer = 1/(1+math.exp(beta*(alpha-u))) - 1/(1+math.exp(beta*alpha))
val denom = 1/(1+math.exp(beta*(alpha-1))) - 1/(1+math.exp(beta*alpha))
val gu = math.max(0.0, math.min(1.0, numer / denom))

Screenshots

The first screenshot shows the original equation, the second one the updated formula as defined by ImageMagick. As you can see, when applying a lower contrast value of beta, the higher values of the rasters will be cut off. This behaviour is less apparent when using higher beta values. However the consequence is that it makes the sigmoidal contrast function very unpredictable.

image

image

JanssenBrm added a commit to JanssenBrm/geotrellis that referenced this issue Dec 22, 2020
JanssenBrm added a commit to JanssenBrm/geotrellis that referenced this issue Dec 29, 2020
Signed-off-by: janssenb <bram.janssen@vito.be>
JanssenBrm added a commit to JanssenBrm/geotrellis that referenced this issue Dec 29, 2020
Signed-off-by: janssenbrm <brm.janssen@gmail.com>
@pomadchin pomadchin added the bug label Dec 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants