HI,
Understand your needs, however, even if I tell you about our algorithm, it won't solve the problem. I have another idea.
Please set the AutoExpTargetBrightness, it should work.
This value will be the final image brightness achieved by auto exposure and auto gain.
Thanks
Chad