1

With the help of this link I  can change the intensity of entire texture. Now I want to detect all points on my texture which have intensity greater than 0.7. How can  I achieve this?

private void CreateShaders()
{
    /***********Vert Shader********************/
    vertShader = GL.CreateShader(ShaderType.VertexShader);
    GL.ShaderSource(vertShader, @"
        attribute vec3 a_position;
        varying vec2 vTexCoord;
        void main() {
            vTexCoord = (a_position.xy + 1) / 2;
            gl_Position = vec4(a_position,1);
        }");
    GL.CompileShader(vertShader);

    /***********Frag Shader ****************/
    fragShader = GL.CreateShader(ShaderType.FragmentShader);
    GL.ShaderSource(fragShader, @"
        precision highp float;
        uniform sampler2D sTexture;
        varying vec2 vTexCoord;
        const float Epsilon = 1e-10;

        //RGBtoHSV
        //HSVtoRGB

        void main ()
        {
            vec4  color = texture2D (sTexture, vTexCoord);
            float u_saturate=0.7;
            vec3 col_hsv = RGBtoHSV(color.rgb);
            col_hsv.z *= (u_saturate * 2.0);
            vec3 col_rgb = HSVtoRGB(col_hsv.rgb);
            gl_FragColor = vec4(col_rgb.rgb, color.a);
        }");
    GL.CompileShader(fragShader);
}
Rabbid76
  • 202,892
  • 27
  • 131
  • 174
H.NS
  • 75
  • 7
  • What do you mean by *"detect all points"*. What will you do with this points, respectively with the other points? – Rabbid76 Aug 21 '19 at 07:35
  • Now I want to highlight this points with black color. later I want to compare this points with same points of another texture. – H.NS Aug 21 '19 at 07:39

1 Answers1

0

Compare the intensity to a threshold and use a different color dependent on the intensity:

gl_FragColor = intensity > 0.7 ? colorH : vec4(col_rgb.rgb, color.a);  

The fragment shader main may look like this:

void main ()
{
    vec4  color = texture2D (sTexture, vTexCoord);
    float u_saturate=0.7;

    vec3  col_hsv = RGBtoHSV(color.rgb);
    float intensity = col_hsv.z;

    col_hsv.z *= (u_saturate * 2.0);
    vec3 col_rgb = HSVtoRGB(col_hsv.rgb);   

    vec4 colorH = vec4(0.0, 0.0, 0.0, 1.0);
    gl_FragColor = intensity > 0.7 ? colorH : vec4(col_rgb.rgb, color.a);
}
Rabbid76
  • 202,892
  • 27
  • 131
  • 174
  • Can you please help me on https://stackoverflow.com/questions/57622908/change-the-intensity-of-an-image-by-comparing-intensity-of-another-image-opent – H.NS Aug 23 '19 at 08:59