Invert luminance ofxCvGrayscaleImage

Hello, I got the kinect working on windows, using VS2010. Now I want to invert the luminance. I’m working with GL_ALPHA instead of GL_LUMINANCE but the issue should be the same. White (or alpha) has to be black and black has to be white (or alpha). Do I have to make some more changes to ofxCvGrayscaleImage.cpp? Or has it something to do with the far and near threshold? Everything that is over 3 meters away from the kinect has to be black.

There is an invert() method on the ofxCvGrayscaleImage that should invert it. Or you could simple write a shader that looks at the incoming pixel and sets it black if it’s below a certain threshold.

  
uniform sampler2DRect tex;  
  
void main()  
{  
	vec4 p = texture2D(tex, gl_TexCoord[0].xy);  
	if(p.w < 0.6)   
		gl_FragColor = vec4(0, 0, 0, 1);  
	else  
		gl_FragColor = gl_Color * p;  
}  
  

I’d try the invert() first and see if it’s too slow and if so, go with a shader.

if you are using ofxKinect, there’s actually this method:

  
void enableDepthNearValueWhite(bool bEnabled=true);  

which reverses white for near or far

Thanks a lot, I just needed to set the Image Filter Operations: ofxCvGrayscaleImage::treshold and ofxCvGrayscaleImage::adaptive threshold invert to true. :slight_smile:

Another question, is there an easy way to smoothen or blur the noisy signal from the kinect?