PDA

View Full Version : Increasing Brightness/Contrast of an Image



kiock
04-26-2006, 02:52 PM
Hi I was wondering how could I increase the brightness of a picture.

I would like to create the same effect as the image below.
http://img142.imageshack.us/img142/7906/brainscan3ag.png

Also is there some way to perhaps only have pixels that are above/below a certain grey level be brightened?

I'm quite new to OpenGL and so don't really have any idea what I could use to do this. Any and all help is very welcome.

Thank you.

songho
04-26-2006, 03:29 PM
kiock,
Once you got the pixel data from the source image, you can modify each pixel by yourself.

The brightness is shifting the value of each pixel:
out[i] = in[i] + offset;

and contrast is modulation(scaling up/down the value):
out[i] = in[i] * scale;

Probably, you may need histogram streching or histogram equaliztion to enhance the input image.
This is a screenshot that I did before:
http://songho.ca/dsp/histogram/files/histoEqualization.png

kiock
04-26-2006, 04:56 PM
Thank you very much song!

I don't completely understand this but I'll have a look at my resources.

Do you suggest anywhere that has information on subjects such as this?

Thank you again.

songho
04-26-2006, 08:50 PM
kiock,
If you want to know about histogram method, please search "contrast(histogram) stretching" and "histogram equaliztion". You will have many resources from the net.

Adjusting brightness and contrast is very easy as I described in the previous post, so you can easily implement into your program. Just watch out min and max values of the data type.

I can give you the source code of above example. Let me know if you are interested in.

tibit
04-26-2006, 10:33 PM
Programs like Paint Shop Pro have a tool to increase the gamma. This is much better than
just increasing the brightness of every pixel. I think it is very easy to do. A gamma
table (256 values for each R,G,B component, so 256*3 total entries) is first calculated
for some given gamma value, say, 1.5, then every pixel is replaced with its gamma
table value entry. You can probably find some code on Google.

bhavana
10-08-2010, 12:14 AM
Hi,
I have created shader for brightness in QT, also I have draw an Image on shader but actualy my problem is how i will update the brightness value in Image??
Iam new User Of OpenGl Shader so rely Iam not getting any idea....
Please Reply me soon....

Thanks In Advance...

Alfonse Reinheart
10-08-2010, 12:41 AM
You felt the need to resurrect a 4-year-old thread to ask this question?