颜色校正

来源:互联网 发布:图像骨架提取算法 编辑:程序博客网 时间:2024/04/30 00:10

转自 http://blog.csdn.net/cnjet/article/details/40582315


Introduce

    Color correction is general term(refer to wiki), in video game, it's also called 'color grading'.

        Color grading is the process of altering and enhancing the color of a motion picture, video image, or still image either electronically, photo-chemically or digitally.    ---- From wiki page

    In theory, it's done by mapping a color to another color. Gamma correction is most famous color correction effect. It will transform RGB color to sRGB color with power(2.2) operation. Most of the time, this kind of mapping will include many complex operations. To accelerate real-time performance, most of game will use a 3D lookup table to realize color grading. This 3D lookup texture should be with very small size and usually offline created by artist outside of game engine by 3rd party software(such as Photoshop). Also, it can be generated dynamically.

Ideas

    Most of photo process and video process software support color correction in some kind of way. 

 

 

    In general, there are two solutions for adjusting color grading:

    1. A curve can be modified by some key points:

Color Curve in GIMP

    Very powerful and more flexible to control. But it's hard to understand for artist. some parameters based curve should be applied such as bezier curve.

    2. Some predefined effect with parameters:

    

Brightness and Contrast in GIMP

    More easy to understand.So, most of software will support it.

 

    There's many kinds of color correction effect exist. Different software will support different subset of them.

  • Brightness
    Make whole scene more bright or more dark.
  • Contrast
    Make whole scene have more contrast, dark more dark, bright more bright.With negative value, it will reduce the effect. 
  • Hue
    Change color hue.
  • Saturation
    Change color saturation.
  • Exposure
    Control the exposure of image.
  • Color balance
    Control the color balance of image.
  • Gamma
    Normally, convert from RGB to sRGB.
  • ...

 

    When combining different effects together, three different solutions exist:

    1. Each effect is treated as one node with parameters. Then all effect nodes will applied one by one according the order in the sequence.

    2. Some effects are combined into small groups. A static order of the effects are used in the group. Several small group will be applied one by one.

    3. Combine all supported effects into one group. The group can be applied more than once.

 

     Most of software also support only affect these effect on separate color channel(R, G, B, H, S, V, L). Some of effect can only affect shadows(such as [0,0.2]), midtones(such as (0.2,0.7]), highlights(such as (0.7,1.0]). Different software have different subset of color correction effects. Even same color correction effect will be implemented by different method(mathematical function or curve). 

Conclusion

    As previous description about Lynx color correction feature and the research result of different software. Following is the design:

    1. A new computer shader will be used to generate 3D LUT texture at runtime; It should be executed every frame or only some special frame according to performance requirement;

    2. The 3D LUT texture should be small size to reduce the texture fetching cost on GPU; At same time keeping good visual quality; Similar with Trials Fusion, it's 32x32x16.

    3. To keep high performance and simplify the usage, all support color correction features are combined into one shader with static order:

  • Contrast
  • Hue, Saturation and Exposure
  • Brightness
  • Color balance
  • Gamma

     4. Different color correction effect has some parameter to control result. They are all exposed in shader constant buffer, the correct values are need to calculated in CPU side.

     Detail implementation refer to HDR demo.

 

     There are many color correction effects for different purpose, current implementation only realize basic color correction effect. Some other effect can be added later according to requirement. 

  • Contrast
    <new color> = <old color> + <contrast> * (<old color> - 0.5)
  • Hue, Saturation and Exposure
    All these operation are done in HSL color space, luminace value is used to simulator exposure. 
    <new color> = convertHSLToRGB( convertRGBToHSL(<old color>) * <hue, saturation, exposure> )
  • Brightness
    <new color> = <old color> + <constant>
  • Color balance
    <new color> = <old color> * <color balance(r,g,b)>
  • Gamma
    <new color> = pow( <old color>, 1/gamma)

Reference:

  1. Color correction on Wiki: http://en.wikipedia.org/wiki/Color_correction
  2. Color grading on Wiki: http://en.wikipedia.org/wiki/Color_grading
  3. Using Lookup Tables to Accelerate Color Transformations: http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter24.html
  4. Brightness, Constrast, Saturation, and Sharpness: http://www.steves-digicams.com/knowledge-center/brightness-contrast-saturation-and-sharpness.html
  5. List of color space and their uses: http://en.wikipedia.org/wiki/List_of_color_spaces_and_their_uses
  6. Unreal3 HSV&RGB conversion function: http://wiki.beyondunreal.com/HSV-RGB_Conversion
  7. Unreal Legacy:Colors: http://wiki.beyondunreal.com/Legacy:Colors
  8. NVIDIA shader library(color space operation): http://developer.download.nvidia.com/shaderlibrary/webpages/hlsl_shaders.html
  9. Optimized RGB to HSL/HSV and HSL/HSV to RGB: http://www.chilliant.com/rgb2hsv.html
  10. Color grading in blender: http://wiki.blender.org/index.php/Doc:2.6/Manual/Composite_Nodes/Types/Color
  11. Enhancing Photographs in Gimp: http://docs.gimp.org/en/gimp-imaging-photos.html
  12. CLUT: http://www.quelsolaar.com/technology/clut.html
0 0
原创粉丝点击