Jump to content


Photo

A Macro For Correct Defocus


  • Please log in to reply
7 replies to this topic

#1 Gringo

Gringo

    Associate Administrator

  • Adv Members
  • PipPipPipPipPip
  • 1,455 posts

Posted 13 January 2008 - 03:52 PM

This macro allows to make correct defocus on sRGB (not true-linear) images.
Note that it sets color depth to 32 bit to avoid banding. You can return color depth to initial right after the macro node using the ColorDepth tool.

Attached Files



#2 Gringo

Gringo

    Associate Administrator

  • Adv Members
  • PipPipPipPipPip
  • 1,455 posts

Posted 13 January 2008 - 04:04 PM

By the way, all the creators, loaders and the pRender, Render3D tools are initially gamma-corrected while other tools assume that they are applied to true linear images...
I wonder, what algorithm is used for the conversion? sRGB or simplified sRGB?

Maybe, it's worth to create an additional parameter in Image tab to select color space for ones that want to use true linear workflow?

#3 Daniel Koch

Daniel Koch

    Flying Pig

  • Adv Members
  • PipPipPipPipPip
  • 661 posts

Posted 22 January 2008 - 02:07 AM

By the way, all the creators, loaders and the pRender, Render3D tools are initially gamma-corrected while other tools assume that they are applied to true linear images...

That's actually not the case.

The result from a loader is exactly what the image file data contained. No gamma is applied, except by the Cineon/DPX loader, and those are controllable. If the image is linear on disk, it's linear within Fusion. If it already has an inherent gamma applied to the image data (as e.g. filmstock often does), then that will be preserved into Fusion. If need be, a BC tool can be used to de-gamma loaded footage before further processing.

Creators like Background, Text+, pRender, Render3D all produce linear output, and should (for ideal results) be given linear textures etc to work with.

For many applications this isn't completely necessary, and blending two similarly-gamma'd images still looks good enough. For more physically accurate results, or when working with clips with different gamma, it is recommended that all frames be linearised appropriately, processed as linear, and any necessary gamma be applied in the display view and on final output.

#4 shaily

shaily

    Flying Pig

  • Adv Members
  • PipPipPipPipPip
  • 380 posts

Posted 22 January 2008 - 04:17 AM

This macro allows to make correct defocus on sRGB (not float point) images.
Note that it should set color depth to 32 bit to avoid banding. You can return color depth to initial right after the macro node using the ColorDepth tool.

i believe sRGb is a little more complex than gamma 2.2, i dont know the exact math though.
simplified sRGB is 2.2 which is a very close and practical approximation of sRGB
you can use tools->Color->Gamut to do the conversion.

shaily.

#5 Gringo

Gringo

    Associate Administrator

  • Adv Members
  • PipPipPipPipPip
  • 1,455 posts

Posted 22 January 2008 - 08:18 PM

Daniel, thank you for the explanation here and at www.vfxpedia.com!

If consider non-linear human retina response, it seems that digital images are really true-linear and display gamma is about to be compensated by the gamma of our perception...

So, sRGB gamma is just the question of samples density. sRGB has more samples near to 0 and less samples near to 1 while the 8 bit BG tool in Fusion has evenly distributed samples between 0 and 1...

But some things are not clear for me.
Real world is true linear. And we see it gamma-corrected due to our sight properties. It explains, for example, the visual difference and correlation between direct vision and reflection in semi-reflective surfaces like car paint and glass.
Digital images are true linear. And we see them... true linear due to our sight/our display properties...

If we take a DPX sequence with focus pull so that in one frame an object is focused and in another it's out of focus, then import it with Display Gamma = 2.2 (in this case it should look OK) and try to apply the Defocus tool we'll see the CG-defocus differs from real one.
But if we load the DPX with Display Gamma = 1, the real-shot defocus will be almost the same as the CG one. And the picture will look too dark unlike common TGAs or Fusion creators...
Applying display LUT with Gamma = 2.2 we can make the picture from the DPX with correct defocus look OK. But in this case gradient in the BG tool will not look linear.

I think there would be no conversations about gamma if all worked fine. But in traditional work flow, we always need to make some tricks to reproduce the real-world effects.

Sorry, I just want to clarify this gamma-mess.

i believe sRGb is a little more complex than gamma 2.2, i dont know the exact math though.
simplified sRGB is 2.2 which is a very close and practical approximation of sRGB
you can use tools->Color->Gamut to do the conversion.

Yes, I know about the small linear segment in the darks, but I use simple gamma to give possibility of smooth increasing or decreasing the effect.

#6 Gringo

Gringo

    Associate Administrator

  • Adv Members
  • PipPipPipPipPip
  • 1,455 posts

Posted 23 January 2008 - 04:51 PM

Here is a similar macro for motion blur. It also uses de-gamma operation to create physically-correct effect on sRGB images.

It's evident, that the key is difference between gamma of the picture an effect is applied to and gamma of the picture our brain perceives. If gamma is increased after the effect is applied, it looks right.

Attached Files



#7 Gringo

Gringo

    Associate Administrator

  • Adv Members
  • PipPipPipPipPip
  • 1,455 posts

Posted 26 October 2008 - 06:02 AM

Updated versions of the macros:
Correct behavior at edges of objects and some minor improvements.

Attached Files



#8 Gringo

Gringo

    Associate Administrator

  • Adv Members
  • PipPipPipPipPip
  • 1,455 posts

Posted 23 October 2009 - 06:50 AM

In this new version controls were named correctly to be used in simple expressions, the Common Controls tab with additional mask controls was added.

Attached Files






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users