I wont to set contrast / brightnes on image witch is in form byte[]. The image is in YCbCr_420 color space (android camera). I am geting luma value this way :
f
YUV processing is best demonstrated in the APLEAGLView.m file of this sample app:
https://developer.apple.com/library/ios/samplecode/AVBasicVideoOutput/Listings/AVBasicVideoOutput_APLEAGLView_m.html#//apple_ref/doc/uid/DTS40013109-AVBasicVideoOutput_APLEAGLView_m-DontLinkElementID_6
Proper adjustments to brightness and contrast so that they maintain their relationship in proportion to each other is demonstrated in the Shader.fsh file at:
https://developer.apple.com/library/ios/samplecode/AVBasicVideoOutput/Listings/AVBasicVideoOutput_Shaders_Shader_fsh.html#//apple_ref/doc/uid/DTS40013109-AVBasicVideoOutput_Shaders_Shader_fsh-DontLinkElementID_9
If you need help interpeting the code, I can help. For now, though, using a user-specified luma threshold value, the luma-adjusted Y plane is calculated like this:
Y' = (Y - (16 / 255)) * lumaThreshold;