Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

How Photoshop or other image editing software change an images contrast? What contrast mean when we process image pixel by pixel? Or what image contrast means?

Here I created a very basic image to understand image contrast. This is a 10×10 pixels image that get a 100% non-legacy contrast adjustment in Photoshop. The only change I saw was in gray colors that were lighter after applying the contrast.

Before and after contrast:

The images before and after contrasts are similar, except for the gray color which is slightly lighter

share|improve this question
    
You could try Signal Processing Community if you want a theoretical answer. –  Dipan Mehta Mar 12 '12 at 3:04
add comment

2 Answers

up vote 4 down vote accepted

Actually, there are two very different algorithms in Adobe Photoshop CS3 or later.

The old one just shifts linearly the color of a pixel. The second one works proportionally. If your intent is to understand, in general, how contrast is applied, use the legacy contrast only. Here's an image showing a difference:

The new contrast shows no difference. The legacy contrast is very different from the original image.

When using legacy contrast, you see that it's much more intuitive from developers point of view. It actually lightens the dark pixels, and darkens the light ones when reducing the contrast. When increasing the contrast, you will see the same happening with gray color (turning lighter, then white at 100%), while blank and white staying the same.

From the point of view of photographers, on the other hand, this doesn't make any sense. As you can see below, when applied to real images, the new contrast algorithm has much better visual results than the old one:

enter image description here

enter image description here

See also:

share|improve this answer
add comment

Contrast is fairly simple. Increasing contrast means making bright pixels brighter and dark pixels darker; decreasing contrast is the opposite. So what you do is, per pixel: calculate the pixel's brightness, and move it toward or away from a center value (0.5 if your brightness range is 0 to 1).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.