Camera response functions as a tonemapping option

Discussion related to the implementation of new features & algorithms to the Core Engine.

Moderators: jromang, tomb, zcott, coordinators

Camera response functions as a tonemapping option

Postby Daniel90 » Sat Apr 24, 2010 5:23 am

Like the title suggests I'm trying to implement camera response functions as a tonemapping option (like described in issue 632).
The problem is that the tonemappers that we have now (reinhard, linear, contrast and maxwhite) use the XYZ values to apply their algorithms to. The conversion from XYZ to RGB takes place later in the imaging pipeline (not in the tonemapper itself).
But the camera response functions have to be applied to the RGB values.
One option would be to convert XYZ -> RGB, apply the response function and convert back to XYZ. Then the imaging pipeline would again convert from XYZ -> RGB.

Because this is wasted computing time LordCrc suggested that the tonemappers themselves have to apply the conversion from XYZ to RGB. That requires not much change to the code and seems like a good solution to me.

Another suggestion of LordCrc is to apply the camera response function *after* (and additionally to) the tonemapping. But I don't know if this is correct. Does anybody know how Indigo uses CRFs? As a real tonemapping option or as an addition to the tonemapping?
Daniel90
 
Posts: 62
Joined: Sun Aug 23, 2009 8:42 am
Location: Germany

Re: Camera response functions as a tonemapping option

Postby dougal2 » Sat Apr 24, 2010 6:53 am

Indigo implements the CRF function as a tonemapper, however I suspect that in reality that tonemapper consists of:
[(XYZ) linear tonemapper (XYZ->XYZ) colourspace converter (XYZ->RGB) CRF processor (RGB)]
User avatar
dougal2
Developer
 
Posts: 3074
Joined: Mon Jan 14, 2008 7:21 am

Re: Camera response functions as a tonemapping option

Postby jeanphi » Sun Apr 25, 2010 8:44 am

Hi,

Please don't reference commercial renderers when discussing algorithm implementation. I don't think this matters in this particular case, but better safe than sorry.
To the point, I think that currently the best thing would probably be to move XYZ->RGB to the tonemapping. They are already done just one after the other and will make it easier to add those fancy options. However you'll have to keep the current xyzpixels/rgbpixels in ApplyImagingPipeline to make it clear what data you have in the buffer. It will also require a protoype change for the tonemappers (have both an input buffer of XYZColor and an output buffer of RGBColor) so that you don't do fancy type casting in them too.

Jeanphi
jeanphi
Developer
 
Posts: 6577
Joined: Mon Jan 14, 2008 7:21 am

Re: Camera response functions as a tonemapping option

Postby Daniel90 » Mon Apr 26, 2010 8:54 am

I've got some examples for camera response function "corrected" pics :D
They're all tonemapped with the linear tonemapper at a sensitivity of 50, an exposure of 0.11, an f-stop of 16.5 and a gamma of 1.

linear_50_0,11_16,5_1_gamma-corrected_no-film.jpg
The original image (no film used)

linear_50_0,11_16,5_1_gamma-corrected_Advantix-100CD.jpg
Advantix 100CD

linear_50_0,11_16,5_1_gamma-corrected_agfacolor-optimaII-100CD.jpg
Agfacolor OptimaII 100CD

linear_50_0,11_16,5_1_gamma-corrected_agfapan-apx-100CD.jpg
Agfapan APX 100CD

linear_50_0,11_16,5_1_gamma-corrected_F125CD.jpg
F125CD

linear_50_0,11_16,5_1_gamma-corrected_FP2900Z.jpg
FP2900Z

linear_50_0,11_16,5_1_gamma-corrected_Kodachrome-200CD.jpg
Kodachrome 200CD

linear_50_0,11_16,5_1_gamma-corrected_Portra-400NCCD.jpg
Portra 400NCCD

Some films show an obvious bluish or reddish tint, but that seems to be right. Maybe it is so obvious because the background of my test scene is so uniformly grey.
Daniel90
 
Posts: 62
Joined: Sun Aug 23, 2009 8:42 am
Location: Germany

Re: Camera response functions as a tonemapping option

Postby tomb » Mon Apr 26, 2010 9:18 am

Very nice!
User avatar
tomb
Developer
 
Posts: 1919
Joined: Thu Oct 11, 2007 4:23 pm
Location: Oslo, Norway

Re: Camera response functions as a tonemapping option

Postby SATtva » Mon Apr 26, 2010 9:43 am

Holy-moly! I'm in love. ^__^
Linux builds packager
聞くのは一時の恥、聞かぬのは一生の恥
User avatar
SATtva
Developer
 
Posts: 5495
Joined: Tue Apr 07, 2009 12:19 pm
Location: from Siberia with love

Re: Camera response functions as a tonemapping option

Postby jeanphi » Mon Apr 26, 2010 9:56 am

Hi,

The gamma of the linear tonemapper should ALWAYS match the output gamma, because the ISO definition for digital images depends on the mapping of the gamma corrected image. So if you use a camera response, you should even factor that in the tonemapping conversion factor. The only other interpretation I can see is that the gamma should be hardcoded to 2.2, but not 1.

Jeanphi
jeanphi
Developer
 
Posts: 6577
Joined: Mon Jan 14, 2008 7:21 am

Re: Camera response functions as a tonemapping option

Postby Daniel90 » Mon Apr 26, 2010 10:03 am

argh, the above example images are already out of date ;)

LordCrc said that it would be more plausible to apply the inverse gamma correction after and not before the crf.
Now also the bluish and reddish tints vanished (or at least got weaker; depending on the film used).
I'll post new example images later.
Last edited by Daniel90 on Tue Apr 27, 2010 5:40 am, edited 1 time in total.
Daniel90
 
Posts: 62
Joined: Sun Aug 23, 2009 8:42 am
Location: Germany

Re: Camera response functions as a tonemapping option

Postby jeanphi » Mon Apr 26, 2010 10:06 am

Hi,

Applying the gamma correction after tonemapping makes perfect sense as this is a display correction, tonemapping is a sensor correction.

Jeanphi
jeanphi
Developer
 
Posts: 6577
Joined: Mon Jan 14, 2008 7:21 am

Re: Camera response functions as a tonemapping option

Postby Daniel90 » Tue Apr 27, 2010 11:29 am

I revised my code and created new previews with the help of LordCrc's nice color chart scene.
In the top left you can see the original image without a CRF.

Overview.jpg
Results after applying some different CRFs
Daniel90
 
Posts: 62
Joined: Sun Aug 23, 2009 8:42 am
Location: Germany

Next

Return to Architecture & Design

Who is online

Users browsing this forum: No registered users and 2 guests