openexr-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Openexr-devel] how exr images are displayed


From: Tensor G
Subject: [Openexr-devel] how exr images are displayed
Date: Thu, 26 Feb 2004 16:39:25 +0000

hello all,

first of all, thx for your hints about configuring EXR. following your instructions i was able to make all the thing run. Now i was looking at the exrdisplay program, tring to figure out how to manage exr images. Useless to say, i did get stuck :) If u don't mind giving a lil help to a newbie wanting to get started... here are my questions:
I refer to the comments of the ImageView.cpp file:

// Conversion from raw pixel data to data for the OpenGl frame buffer:

//  1) Compensate for fogging by subtracting defog
//     from the raw pixel values.

Q_1) I understand that this fog isn't like OpenGL fog function... now what does it represent? In the function computeFog the fog values are calculated like
(SUM ( *finite* pixel colors)) / NUMBER_OF_PIXELS
it seems like the avrg value of the image colors, but it isn't really making sense to me...
Q_1.1) BTW can a pixel be NON_finite?

//  2) Multiply the defogged pixel values by
//     2^(exposure + 2.47393).

Q_2) what does 2.47393 represent? Can't think of a phisical constant with suck value... not that i argue cut n'pasting, but i'd like to understand a bit more the basis of image processing...

//  3) Values, which are now 1.0, are called "middle gray".
//     If defog and exposure are both set to 0.0, then
//     middle gray corresponds to a raw pixel value of 0.18.
//     In step 6, middle gray values will be mapped to an
//     intensity 3.5 f-stops below the display's maximum
//     intensity.

Q_3) Why middle gray with exp & fog == 0 MUST be 0.18? Just a convention? Why 3.5 f-stops below MAX intensity? Middle_gray is what I use to compute all other colors, isn't it?

//  4) Apply a knee function.  The knee function has two
//     parameters, kneeLow and kneeHigh.  Pixel values
//     below 2^kneeLow are not changed by the knee
//     function.  Pixel values above kneeLow are lowered
//     according to a logarithmic curve, such that the
//     value 2^kneeHigh is mapped to 2^3.5 (in step 6,
//     this value will be mapped to the the display's
//     maximum intensity).

Q_4) This is the real top -> first question:
// value 2^kneeHigh is mapped to 2^3.5 => does it means 2^kneeHigh = 2^3.5???? it is impossible, since kneeHigh is a constant!! that is not an equation, just an identity. Can't really understand that thing.
Q_4.1) I post a bunch of code...



// static float ImageView::knee (float x, float f)
{
   return Imath::Math<float>::log (x * f + 1) / f;
}

// static float ImageView::findKneeF (float x, float y)
{
   float f0 = 0;
   float f1 = 1;

// Q_4.2) WHAT LOG (X*F1+1)/F REPRESENT? ANY PARTICULARY FUNC I SHOULD KNOW OR ANY DECREASING LOG FUNC SHOULD FIT?
   while (knee (x, f1) > y)
   {
        f0 = f1;
        f1 = f1 * 2;
   }

//Q_4.3) WHY 30 CYCLES?
   for (int i = 0; i < 30; ++i)
   {
        float f2 = (f0 + f1) / 2;
        float y2 = knee (x, f2);

        if (y2 < y)
            f1 = f2;
        else
            f0 = f2;
   }

   return (f0 + f1) / 2;
}

...

struct Gamma
{
   float m, d, kl, f;

   Gamma (float exposure, float defog, float kneeLow, float kneeHigh);
   unsigned char operator () (half h);
};


Gamma::Gamma (float exposure, float defog, float kneeLow, float kneeHigh):
   m (Imath::Math<float>::pow (2, exposure + 2.47393)),
   d (defog),
   kl (Imath::Math<float>::pow (2, kneeLow)),


//Q_4.3) WHAT DOES THIS F REPRESENT? LOGARTIMIC INTERPOLATION BETWEEN 2^KNEEHIGH AND 2^3.5? WHY THE -KL THING?
   f (ImageView::findKneeF (Imath::Math<float>::pow (2, kneeHigh) - kl,
                             Imath::Math<float>::pow (2, 3.5) - kl))
{}


//  5) Gamma-correct the pixel values, assuming that the
//     screen's gamma is 2.2 (or 1 / 0.4545).

Q_5) 2.2 is just a common value, nothing exotic here, right?

//  6) Scale the values such that pixels middle gray
//     pixels are mapped to 84.66 (or 3.5 f-stops below
//     the display's maximum intensity).

Q_6) Why 84.66? my middle gray was 0.18, then i'd say
0.18:1=x:255   =>  x=255*0.18/1  => x=45.9!

//  7) Clamp the values to [0, 255].

the only part i fully agree :)

Q_7) f-stop == 56.78?

thx for any help... i am just a humble OpenGL programmer tring to scout new territories :)

_________________________________________________________________
Personalizza MSN Messenger con sfondi e fotografie! http://www.ilovemessenger.msn.it/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]