views:

183

answers:

2

adjust image brightness/contrast using c++ without using any other 3rd party library or dependancy

+1  A: 

Image brightness is here - use the mean of the RGB values and shift them.

Contrast is here with other languages solutions available as well.

Michael Dorgan
contrast code have some dependancies to GDI + dotnet framework
JKS
+1  A: 

Read in the image with a library just as the Independent JPEG library. When you have raw data, you can convert it from RGB to HSL or (preferably) CIE L*a*b*. Both contrast and brightness will basically just involve adjustments to the L channel -- to adjust brightness, just adjust all the L values up or down by an appropriate amount. To adjust contrast, you basically adjust the difference between a particular value and the center value. You'll generally want to do this non-linearly, so values near the middle of the range are adjusted quite a bit, but values close to the ends or the range aren't affected nearly as much (and any that are at the very ends, aren't changed at all).

Once you've done that, you can convert back to RGB, and then back to a normal format such as JPEG.

Jerry Coffin