I have two images. I have to found the points of first image which have intensity greater than 0.8. At the same time I have to found the intensity of second image on same points and need to adjust the light on second image on same points with a threshold/slider value(ranges from 0 to 1). I have done like below. Getting black or dark area on points have intensity greater than 0.8.
I'm trying with z value of HSV.
But instead of this black area I should be able to adjust the light on image2. How can I achieve this?
public void CreateShaders()
{
/***********Vert Shader********************/
vertShader = GL.CreateShader(ShaderType.VertexShader);
GL.ShaderSource(vertShader, @"
attribute vec3 a_position;
varying vec2 vTexCoordIn;
void main() {
vTexCoordIn=( 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 sTexture1;
uniform sampler2D sTexture2;
varying vec2 vTexCoordIn;
const float Epsilon = 1e-10;
uniform float sSelectedIntensity1;//slider value 0 to 1
void main ()
{
vec2 vTexCoord=vec2(vTexCoordIn.x,vTexCoordIn.y);
vec4 color1 = texture2D (sTexture1, vTexCoord);
vec4 color2= texture2D (sTexture2, vTexCoord);
vec3 col1_hsv = RGBtoHSV(color1.rgb);
float col1_intensity =col1_hsv.z;
float ConstVal=0.8;
if(col1_intensity>ConstVal)
{
vec3 col_hsv = RGBtoHSV(color2.rgb);
col_hsv.z *= sSelectedIntensity1;//slider value 0 to 1
vec3 col_rgb = HSVtoRGB(col_hsv.rgb);
gl_FragColor = vec4(col_rgb.rgb, color2.a);
}
else
{
gl_FragColor = color2;
}
}");
GL.CompileShader(fragShader);
}
Practically, if image1 and image2 are frames coming from two adjusent cameras cam1 and cam2 respectively. And if I put a flash light infront of cam1, i should be able to dim/remove this light effect on frames of camera 2.