<commit_before>/**
 * @author <NAME> / Copyright Orange 2013
 * 
 * Filter allowing to calculate the gaussian mixture of an input frame 
 * relative to a reference frame:
 * -the R,G,B components of the output will contain the mean color
 * components value,
 * - the alpha component decreases with the variance ('noisy' pixels
 * are given a low alpha value)
 * 
 * ratio: the mixture ratio (0 to 1)
 * 
 */
(function(global) {

    // Register this filter
    global.addFilter(
        // Filter name
        'gaussmix',
        // Vertex Shader (null uses default)
        null,
        // Fragment Shader (null uses default)        
        '\
        uniform sampler2D texture;\
        uniform sampler2D reference;\
        uniform float ratio;\
        varying vec2 texCoord;\
        void main() {\
            vec4 color = texture2D(texture, texCoord);\
            vec4 rcolor = texture2D(reference, texCoord);\
            float dist2 = pow(color.r-rcolor.r,2.0);\
            dist2 += pow(color.g-rcolor.g,2.0);\
            dist2 += pow(color.b-rcolor.b,2.0);\
            float invsig2 = 1.0 - dist2/3.0;\
            gl_FragColor = vec4(\
                color.rgb*ratio + rcolor.rgb*(1.0-ratio),\
                invsig2*ratio + rcolor.a*(1.0-ratio));\
        }\
        ',
        // Uniforms callback
        function (gl, program, frameIn, frameOut, reference, ratio) {
            // Bind reference texture at position 1
            gl.activeTexture(gl.TEXTURE1);
            gl.bindTexture(gl.TEXTURE_2D, reference.asTexture());
            // Set reference uniform to position 1
            var refLocation = gl.getUniformLocation(program, "reference");
            gl.uniform1i(refLocation, 1);<commit_msg>gaussmix: Improved noise factor calculation<commit_after>/**
 * @author <NAME> / Copyright Orange 2013
 * 
 * Filter allowing to calculate the gaussian mixture of an input frame 
 * relative to a reference frame:
 * -the R,G,B components of the output will contain the mean color
 * components value,
 * - the alpha component decreases with the variance ('noisy' pixels
 * are given a low alpha value)
 * 
 * ratio: the mixture ratio (0 to 1)
 * 
 */
(function(global) {

    // Register this filter
    global.addFilter(
        // Filter name
        'gaussmix',
        // Vertex Shader (null uses default)
        null,
        // Fragment Shader (null uses default)        
        '\
        uniform sampler2D texture;\
        uniform sampler2D reference;\
        uniform float ratio;\
        varying vec2 texCoord;\
        void main() {\
            vec4 color = texture2D(texture, texCoord);\
            vec4 rcolor = texture2D(reference, texCoord);\
            float dist2 = pow(color.r-rcolor.r,2.0);\
            dist2 += pow(color.g-rcolor.g,2.0);\
            dist2 += pow(color.b-rcolor.b,2.0);\
            float invsig2 = min(1.0,3.0/dist2);\
            gl_FragColor = vec4(\
                color.rgb*ratio + rcolor.rgb*(1.0-ratio),\
                invsig2*ratio + rcolor.a*(1.0-ratio));\
        }\
        ',
        // Uniforms callback
        function (gl, program, frameIn, frameOut, reference, ratio) {
            // Bind reference texture at position 1
            gl.activeTexture(gl.TEXTURE1);
            gl.bindTexture(gl.TEXTURE_2D, reference.asTexture());
            // Set reference uniform to position 1
            var refLocation = gl.getUniformLocation(program, "reference");
            gl.uniform1i(refLocation, 1);
{'fraction_non_alphanumeric': 0.11136558831949614, 'fraction_numerical': 0.022902948754652163, 'mean_word_length': 1.9610169491525424, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '203309', 'n_tokens_mistral': 1025, 'n_tokens_neox': 977, 'n_words': 292}