LYGIA Shader Library

adaptiveThreshold (lygia/v1.1.6/math/adaptiveThreshold)

adaptive threshold from https://github.com/BradLarson/GPUImage/blob/master/framework/Source/GPUImageAdaptiveThresholdFilter.m

Use:

adaptiveThreshold(<float> value, <float> blur_value [,<float> bias])

Check it on Github


#ifndef FNC_ADAPTIVETHRESHOLD
#define FNC_ADAPTIVETHRESHOLD
float adaptiveThreshold(in float v, in float blur_v, in float b) {
    return step(blur_v + b, v);
}

float adaptiveThreshold(in float v, in float blur_v) {
    return step(blur_v - 0.05, v);
}
#endif

Use:

adaptiveThreshold(<float> value, <float> blur_value[, <float> bias])

Check it on Github


#ifndef FNC_ADAPTIVETHRESHOLD
#define FNC_ADAPTIVETHRESHOLD
float adaptiveThreshold(in float value, in float blur_value, in float bias) {
    return step(blur_value + bias, value);
}

float adaptiveThreshold(in float value, in float blur_value) {
    return step(blur_value - 0.05, value);
}
#endif

Dependencies:

Use:

adaptiveThreshold(<float> value, <float> blur_value, <float> bias)

Check it on Github



#ifndef FNC_ADAPTIVETHRESHOLD
#define FNC_ADAPTIVETHRESHOLD
inline __host__ __device__ float adaptiveThreshold(float value, float blur_value, float bias) {
    return step(blur_value + bias, value);
}

inline __host__ __device__ float adaptiveThreshold(float value, float blur_value) {
    return step(blur_value - 0.05, value);
}
#endif

LYGIA is dual-licensed under the Prosperity License and the Patron License for sponsors and contributors.

Sponsors and contributors are automatically added to the Patron License and they can ignore the any non-commercial rule of the Prosperity Licensed software (please take a look to the exception).

It's also possible to get a permanent comercial license hook to a single and specific version of LYGIA.

Get the latest news and releases

Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository