This is Interesting: Free Magazines for Graphics designers and webmasters
Home > Archive > Computer Graphics with Photoshop > May 2004 > Exposure and histogram stretching
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Exposure and histogram stretching
|
|
|
| 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.
| |
| Xalinai 2004-05-27, 7:14 am |
| On Wed, 26 May 2004 18:47:11 GMT, phoney.email@yahoo.com (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
| |
|
| On Thu, 27 May 2004 07:35:13 GMT, xalinai_Two@xalinai.de (Xalinai)
wrote:
....[color=darkred]
>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.
| |
| Xalinai 2004-05-27, 12:14 pm |
| On Thu, 27 May 2004 12:40:18 GMT, phoney.email@yahoo.com (Don) wrote:
>On Thu, 27 May 2004 07:35:13 GMT, xalinai_Two@xalinai.de (Xalinai)
>wrote:
>
>...
>
>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
| |
| Gernot Hoffmann 2004-05-27, 7:14 pm |
| phoney.email@yahoo.com (Don) wrote in message news:<40b4e56c.5547930@news.individual.net>...
> 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
| |
|
| On Thu, 27 May 2004 14:15:18 GMT, xalinai_Two@xalinai.de (Xalinai)
wrote:
>
>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.
>
>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.
| |
|
| On 27 May 2004 11:41:09 -0700, hoffmann@fho-emden.de (Gernot Hoffmann)
wrote:
>phoney.email@yahoo.com (Don) wrote in message news:<40b4e56c.5547930@news.individual.net>...
....
>
>
>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
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.
| |
| Gernot Hoffmann 2004-05-28, 4:14 am |
| phoney.email@yahoo.com (Don) wrote in message news:<40b66caa.8126420@news.individual.net>...
> 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
| |
|
| On 28 May 2004 00:17:12 -0700, hoffmann@fho-emden.de (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.
| |
| Gernot Hoffmann 2004-05-28, 7:14 pm |
| phoney.email@yahoo.com (Don) wrote in message news:<40b74a90.549634@news.individual.net>...
> On 28 May 2004 00:17:12 -0700, hoffmann@fho-emden.de (Gernot Hoffmann)
> wrote:
>
>
> 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
| |
|
| On 28 May 2004 11:34:31 -0700, hoffmann@fho-emden.de (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īs rule says: a system of (here) two linear equations
>
>a11*x1 + a12*x2=y1
>a21*x1 + a22*x2=y2
After I looked up Cramerīs rule on the Net I remembered I have a
Collins' Mathematics dictionary right here, within hand reach on my
bookshelf (fx: slaps forehead).
And, sure enough, there's was a perfectly good explanation there as
well.
With easy Internet access we (I!) sometimes forget how it was done
before. There are these things called books and they are quite good.
Instant access and need no batteries! ;o)
Don.
|
|
|
| | Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |
|