Previous Page
PCLinuxOS Magazine
Article List
Next Page

Monitor Gamma Correction Made Simple

by critter

Following the recent death of my desktop computer, I was left with a nice, large spare monitor. It seemed a shame to have it just lying around doing nothing, so I decided to connect it up to my laptop and have a dual display.

I was very pleased with the result, working on the laptop, but having reference material available in an easy to read format right next to it (and I had a large screen to play videos on), was so much better than my restrictive laptop screen.

To complete my new set up, I found a nice wide screen format background that I could span across both screens. Nice!

That was when I noticed it. The colors on each screen were completely different. Now where my wife, who who graduated from art college and is a professional textile designer, would have noticed this immediately, I didn't see anything wrong until I had the two halves of the picture in front of me.

Now that I had seen this difference, and it annoyed the hell out of me.

I fiddled around with all the adjustments I could find, but either one was too watery or the other like a Martian twilight. I turned to the internet for help. After an hour or so of searching I determined that my problem was something called gamma correction. I don't pretend to understand this, but it seems to be a bit like contrast. Fortunately, there is a utility available for Linux users called xgamma to control this, and it is in the PCLinuxOS repositories. Now it’s going to be easy.

No it isn't. This utility allows me to change a number from one to something else for either all of this gamma stuff or for each red, green or blue component part of it. After about fifty or so attempts at 'correcting' my gammas, I had to reset everything back to default values to get some sort of sanity back to my displays.

I may not know what this gamma thing is all about, but I would know if it looked right to me and that is all that matters -- right?! What I need is some sort of instant feedback from xgamma so that I can see the effect as it is applied and gradually, slowly reach some sort of compromise to perfection. Something with slider controls that would allow me to inch slowly towards my goal.

Fortunately I had the basics of such a tool left over from a series of articles I did for the magazine last year about using gtkdialog to add graphical interfaces to scripts. The example I had in mind was used to rotate and resize an image. I decided that I could reuse most of the code, rip out the parts I didn't need such as rotation and the images, redefine the scaling slider to adjust the red gamma and add two more similar sliders for the green and blue gammas.

To use the xgamma utility you supply new values for each of the red, blue and green components that you want to adjust. For example:

xgamma -rgamma 1.15 bgamma 0.97

From this you can see how hit and miss this technique is. By typing a value of 0 for the red gamma I was told bluntly that acceptable values were between 0.100 and 10 so these should be the limits for the sliders but during my previous attempts I found that anything above 2 was almost offensive therefore 0.1 to 2 would be used. The default value is 1 and so that is to where the sliders should default.

I needed to add a timer so that the values would be updated as I made the adjustments and this would give me the real time effect I was looking for. I had used a timer in the final gtkdialog article that I had written for the magazine and so this too was easy to implement. I found that an update interval of 200 milliseconds gave quite smooth results. As most of this 'programming' was simply copy, paste and delete text editing of existing code, it took me a little over half an hour to get a usable utility, less than the time I had spent blundering about previously.

It worked admirably. I added an entry to my start up applications so that the adjustments are made automatically on startup.

xgamma -q -rgamma 1.28 -ggamma 1.04 -bgamma 0.94

My twin monitor set up is not perfect but neither is it annoying or embarrassing and I have another little utility in my toolbox.

The code

Note that the lines in blue should be three lines, each beginning with <action> and ending with </action>. Splitting them will result in an error.

Download the Monitor Correction Script here

Previous Page              Top              Next Page