Exposure and histogram stretching

PE
Posted By
phoney.email
May 26, 2004
Views
586
Replies
10
Status
Closed
PS 6. Somewhat theoretical questions but I hope someone responds.

Using Photoshop, how do I emulate image (histogram) changes resulting from scanner exposure boost? This is not as simple as it may appear:

I ran some tests with my film scanner by increasing exposure by a fixed amount (0.1 ev increments). I then plotted the pixel value increase against ev increments and the result, instead of a straight line, was a slightly upward sloping curve. In other words the histogram did not just move to the right from scan to scan but was actually "stretched" (as expected). Pixels on the left "moved" more slowly than pixels on the right i.e. the distance between darkest and brightest pixels increased with exposure boost (more dynamic range).

Taking the baseline scan (before exposure increases) and applying brightness to it in Photoshop resulted in a different histogram. This time the whole histogram just shifted to the right, but the distance between the darkest and brightest pixels remained the same (same dynamic range).

So, how do I emulate this non-linear exposure histogram "stretching" in PS? I know, "use curves", but how exactly?

And while we’re at it, given an arbitrary starting pixel value and a specific EV exposure increase applied to it, does anyone happen to know the formula to calculate the resulting pixel value?

Don.

Must-have mockup pack for every graphic designer 🔥🔥🔥

Easy-to-use drag-n-drop Photoshop scene creator with more than 2800 items.

XT
xalinai_Two
May 27, 2004
On Wed, 26 May 2004 18:47:11 GMT, (Don) wrote:

PS 6. Somewhat theoretical questions but I hope someone responds.
Using Photoshop, how do I emulate image (histogram) changes resulting from scanner exposure boost? This is not as simple as it may appear:
I ran some tests with my film scanner by increasing exposure by a fixed amount (0.1 ev increments). I then plotted the pixel value increase against ev increments and the result, instead of a straight line, was a slightly upward sloping curve. In other words the histogram did not just move to the right from scan to scan but was actually "stretched" (as expected). Pixels on the left "moved" more slowly than pixels on the right i.e. the distance between darkest and brightest pixels increased with exposure boost (more dynamic range).
Taking the baseline scan (before exposure increases) and applying brightness to it in Photoshop resulted in a different histogram. This time the whole histogram just shifted to the right, but the distance between the darkest and brightest pixels remained the same (same dynamic range).

So, how do I emulate this non-linear exposure histogram "stretching" in PS? I know, "use curves", but how exactly?

If there is room on the brighter side then brightness will do what you have seen – move the whole structure to the right.

To expand the dynamic range try "levels": The darkest point in your image may be RGB (15,15,15), the brightest RGB (200,200,200) then the 186 intensities you have are spread over the full 256 value range (this might lead to banding if there are too few intensities used).

Michael
PE
phoney.email
May 27, 2004
On Thu, 27 May 2004 07:35:13 GMT, (Xalinai)
wrote:

PS 6. Somewhat theoretical questions but I hope someone responds.
Using Photoshop, how do I emulate image (histogram) changes resulting from scanner exposure boost? This is not as simple as it may appear:
….
To expand the dynamic range try "levels": The darkest point in your image may be RGB (15,15,15), the brightest RGB (200,200,200) then the 186 intensities you have are spread over the full 256 value range (this might lead to banding if there are too few intensities used).

The problem is this will be done in a linear fashion i.e. the inserted "holes" will appear at regular intervals.

This is quite different to what happens when the scanner exposure is boosted. There are more "new values" in the highlights than in the shadows.

This is much easier to explain with a picture. Legend:
o=original pixel,
..=holes/new values.
The corresponding histograms after a boost would therefore look something like this:

Levels histogram stretching:
o.o.o.o.o.o.o.o.o.o.o

Scanner exposure boost histogram stretching:
o.o..o…o….o…..o……..o

What I want to know is how to perform the exposure type changes to the histogram in Photoshop (v 6 here).

Don.
XT
xalinai_Two
May 27, 2004
On Thu, 27 May 2004 12:40:18 GMT, (Don) wrote:

On Thu, 27 May 2004 07:35:13 GMT, (Xalinai)
wrote:

PS 6. Somewhat theoretical questions but I hope someone responds.
Using Photoshop, how do I emulate image (histogram) changes resulting from scanner exposure boost? This is not as simple as it may appear:

To expand the dynamic range try "levels": The darkest point in your image may be RGB (15,15,15), the brightest RGB (200,200,200) then the 186 intensities you have are spread over the full 256 value range (this might lead to banding if there are too few intensities used).

The problem is this will be done in a linear fashion i.e. the inserted "holes" will appear at regular intervals.

If all your original intensities fit in the range of 15 to 200 then your image only _has_ a maximum of 186 different intensities.

You see, if your image had exactly 186 pixels, each having one value in the given range, then using the full dynamic range would leave some values unused.

You can try and scan at twice the resolution needed and resample to 50% after using levels – that gives a fine homogenuous histogram as each new pixel value is calculated from four pixels in the original image. The more intelligent approach is to do it right.

This is quite different to what happens when the scanner exposure is boosted. There are more "new values" in the highlights than in the shadows.

Have you noticed that there is a midpoint setting in levels? This controls the distribution curve. Play with it for a while.

If you want to do it right, then correct the setting in the scanner software while you are in the deeper color range of the scanner. The function you need there is not exposure but setting of black and white points, even gamma correction might help.

If you start correcting in the 8bit area in PS you are already lost.

Michael
H
hoffmann
May 27, 2004
(Don) wrote in message news:…
PS 6. Somewhat theoretical questions but I hope someone responds.
Using Photoshop, how do I emulate image (histogram) changes resulting from scanner exposure boost? This is not as simple as it may appear:
I ran some tests with my film scanner by increasing exposure by a fixed amount (0.1 ev increments). I then plotted the pixel value increase against ev increments and the result, instead of a straight line, was a slightly upward sloping curve. In other words the histogram did not just move to the right from scan to scan but was actually "stretched" (as expected). Pixels on the left "moved" more slowly than pixels on the right i.e. the distance between darkest and brightest pixels increased with exposure boost (more dynamic range).
Taking the baseline scan (before exposure increases) and applying brightness to it in Photoshop resulted in a different histogram. This time the whole histogram just shifted to the right, but the distance between the darkest and brightest pixels remained the same (same dynamic range).

So, how do I emulate this non-linear exposure histogram "stretching" in PS? I know, "use curves", but how exactly?

And while we’re at it, given an arbitrary starting pixel value and a specific EV exposure increase applied to it, does anyone happen to know the formula to calculate the resulting pixel value?
Don.

Don,

I can only comment your last question, but not by "exposure":

x1 old left end of histogram
x2 old right end of histogram
u1 new left end
u2 new right end
x input
y old output
v new output

Old: y = x

New: v = x1 +(x-u1)*(x2-x1))/(u2-u1)

Test:
x=u1: v=x1
x=u2: v=x2

Two test points are sufficient, because it´s a linear function. Can you replace (u2-u1)/(x2-x1) by "exposure" ?

A drawing would show:
Old: straight line through y(x1)=x1 and y(x2)=x2
New: straight line through v(u1)=x1 and v(u2)=x2

Best regards –Gernot Hoffmann
PE
phoney.email
May 27, 2004
On Thu, 27 May 2004 14:15:18 GMT, (Xalinai)
wrote:

PS 6. Somewhat theoretical questions but I hope someone responds.
Using Photoshop, how do I emulate image (histogram) changes resulting from scanner exposure boost? This is not as simple as it may appear:

To expand the dynamic range try "levels": The darkest point in your image may be RGB (15,15,15), the brightest RGB (200,200,200) then the 186 intensities you have are spread over the full 256 value range (this might lead to banding if there are too few intensities used).

The problem is this will be done in a linear fashion i.e. the inserted "holes" will appear at regular intervals.

If all your original intensities fit in the range of 15 to 200 then your image only _has_ a maximum of 186 different intensities.
You see, if your image had exactly 186 pixels, each having one value in the given range, then using the full dynamic range would leave some values unused.

You can try and scan at twice the resolution needed and resample to 50% after using levels – that gives a fine homogenuous histogram as each new pixel value is calculated from four pixels in the original image. The more intelligent approach is to do it right.

We’re moving somewhat off topic because my question was not really about dynamic range (I only used dynamic range as an illustration to demonstrate pixel "movement"). What I really I wanted to know was about the laws governing pixel values after a certain exposure is applied.

This is quite different to what happens when the scanner exposure is boosted. There are more "new values" in the highlights than in the shadows.

Have you noticed that there is a midpoint setting in levels? This controls the distribution curve. Play with it for a while.
If you want to do it right, then correct the setting in the scanner software while you are in the deeper color range of the scanner. The function you need there is not exposure but setting of black and white points, even gamma correction might help.

If you start correcting in the 8bit area in PS you are already lost.

All that is very good advice but my question was really about theory behind scanner exposure.

Anyway, Mike Russell gave a general explanation over in
"alt.graphics.photoshop". If anyone is interested I can repost it here.

Thanks Michael!

Don.
PE
phoney.email
May 27, 2004
On 27 May 2004 11:41:09 -0700, (Gernot Hoffmann)
wrote:

(Don) wrote in message news:…
….
And while we’re at it, given an arbitrary starting pixel value and a specific EV exposure increase applied to it, does anyone happen to know the formula to calculate the resulting pixel value?
Don.

Don,

I can only comment your last question, but not by "exposure":
x1 old left end of histogram
x2 old right end of histogram
u1 new left end
u2 new right end
x input
y old output
v new output

Old: y = x

New: v = x1 +(x-u1)*(x2-x1))/(u2-u1)

Test:
x=u1: v=x1
x=u2: v=x2

Two test points are sufficient, because it
H
hoffmann
May 28, 2004
(Don) wrote in message news:…
Hi Gernot,

I’m afraid I don’t follow completely. Can you please explain what do you mean by input (x), old output (y) and new output (v)?
To explain it another way I was expecting the formula to look something like:

u1 = x1 + offset1
u2 = x2 + offset2

or in a general form:

new pixel value = old pixel value + offset

where "offset" is a function of both exposure and of old pixel value.
My tests show that "offset" is directly proportional to both the exposure and the starting (old) pixel value. So:
The larger the initial (old) pixel value, the larger the offset. The larger the exposure, the larger the offset.

Also, I just learned elsewhere that gamma plays an important part in all this and since I work in gamma 2.2 this may account for non-linear pixel value progression.

Don.

Don,

my previous suggestion was a stretching but not the expected one. A new attempt:

The darkest entry in a histogram is at x1, the lightest at x2. x1 should be mapped to u1, e.g. to u1=0.
x2 should be mapped to u2, e.g. to u2=1 (normalized instead of 255).

In a linear space this is a linear function:
v(x) = a + b*x

x is the input and v(x) the modified output.
We know two points:

a + b*x1 = u1
a + b*x2 = u2

The linear equations can be solved by Cramer´s rule.

v(x) = a + x*b = (u1*x2-u2*x1)/(x2-x1) + x*(u2-u1)/(x2-x1)

Special case: u1=0, u2=1
v(x) = (x-x1)/(x2-x1)
v(x1)=0 and v(x2)=1 as expected.

Application for Gamma encoded values
Input x=0..255
Output v=0..255
Replace x by (x/255)^G
Replace v by Round(255*v^(1/G))

Best regards –Gernot Hoffmann
PE
phoney.email
May 28, 2004
On 28 May 2004 00:17:12 -0700, (Gernot Hoffmann)
wrote:

Don,

my previous suggestion was a stretching but not the expected one. A new attempt:

The darkest entry in a histogram is at x1, the lightest at x2. x1 should be mapped to u1, e.g. to u1=0.
x2 should be mapped to u2, e.g. to u2=1 (normalized instead of 255).
In a linear space this is a linear function:
v(x) = a + b*x

x is the input and v(x) the modified output.
We know two points:

a + b*x1 = u1
a + b*x2 = u2

The linear equations can be solved by Cramer
H
hoffmann
May 28, 2004
(Don) wrote in message news:…
On 28 May 2004 00:17:12 -0700, (Gernot Hoffmann)
wrote:

Don,

my previous suggestion was a stretching but not the expected one. A new attempt:

The darkest entry in a histogram is at x1, the lightest at x2. x1 should be mapped to u1, e.g. to u1=0.
x2 should be mapped to u2, e.g. to u2=1 (normalized instead of 255).
In a linear space this is a linear function:
v(x) = a + b*x

x is the input and v(x) the modified output.
We know two points:

a + b*x1 = u1
a + b*x2 = u2

The linear equations can be solved by Cramer´s rule.

v(x) = a + x*b = (u1*x2-u2*x1)/(x2-x1) + x*(u2-u1)/(x2-x1)
Special case: u1=0, u2=1
v(x) = (x-x1)/(x2-x1)
v(x1)=0 and v(x2)=1 as expected.

Application for Gamma encoded values
Input x=0..255
Output v=0..255
Replace x by (x/255)^G
Replace v by Round(255*v^(1/G))

Best regards –Gernot Hoffmann

Hi Gernot,

OK, that makes sense now!

I still have to chase up "Cramer´s rule" on the Net, but at least I have to enough to get going.

Thanks very much, as always.

Don.

Don,

thanks for your friendly feedback.

My Google access is always delayed. Therefore this:

——–

Don,

I hope my idea is correct. Probably you will understand
that these contributions are always "under pressure".

Cramer´s rule says: a system of (here) two linear equations

a11*x1 + a12*x2=y1
a21*x1 + a22*x2=y2

is easily solved by determinants:

D = ! a11 a12 ! = a11*a22-a12*a21
! a21 a22 !

D1 = ! y1 a12 ! = y1*a22 – y2*a12
! y2 a22 !

D2 = ! a11 y1 ! = y2*a11 – y1*a21
! a21 y2 !

x1 = D1/D

x2 = D2/D

Best regards –Gernot Hoffmann
PE
phoney.email
May 29, 2004
On 28 May 2004 11:34:31 -0700, (Gernot Hoffmann)
wrote:

Don,

thanks for your friendly feedback.

No, no, thank you. I find your responses always on target and very helpful!

I hope my idea is correct. Probably you will understand
that these contributions are always "under pressure".

That’s fine. I just needed to be pointed in the right direction.

Cramer

How to Master Sharpening in Photoshop

Give your photos a professional finish with sharpening in Photoshop. Learn to enhance details, create contrast, and prepare your images for print, web, and social media.

Related Discussion Topics

Nice and short text about related topics in discussion sections