User Tools

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
isp:gen5-gamma [2026/01/13 23:36] – created Igor Yefmovisp:gen5-gamma [2026/01/27 05:40] (current) – [RGB UVC Gamma Adjustment] Igor Yefmov
Line 1: Line 1:
-====== YUV 4:4:4 UVC Gamma Correction ======+====== RGB UVC Gamma Adjustment ======
  
-At this stage of the imaging pipeline the pixel data is already represented in +At this stage of the imaging pipeline the pixel data is represented in 
-full-range YCbCr 4:4:4 color space with 12-bit precision per component, as +full-range RGB color space with 12-bit precision per component, as produced by 
-produced by the RGB-to-YCbCr conversion stage +the CMX stage ([[isp:gen5-cmx]]).
-([[isp:gen5-rgb-to-yuv]]).+
  
-The purpose of this block is to apply **UVC gamma correction** to the luma +The purpose of this block is to apply **UVC gamma adjustment** in **RGB space** 
-component while leaving chroma components unmodified.+by applying the **same LUT** to all three channels (baseline implementation). 
 +This avoids the undesired desaturation artifacts caused by applying a nonlinear 
 +transfer function to luma-only in YCbCr.
  
 This block is intended to be implemented in FPGA logic and therefore avoids This block is intended to be implemented in FPGA logic and therefore avoids
 runtime floating-point arithmetic. runtime floating-point arithmetic.
 +
 +After this stage completes, the next pipeline stage is the RGB-to-YCbCr
 +conversion stage ([[isp:gen5-rgb-to-yuv]]).
  
 ===== Input format ===== ===== Input format =====
-The input consists of YCbCr pixels with the following properties:+The input consists of RGB pixels with the following properties:
  
 \[ \[
- Y12 \in [0..4095]\\ + R12 \in [0..4095]\\ 
- C_b12 \in [0..4095]\text{, neutral at }2048\\ + G12 \in [0..4095]\\ 
- C_r12 \in [0..4095]\text{, neutral at }2048+ B12 \in [0..4095]
 \] \]
  
Line 27: Line 31:
  
 \[ \[
- Y12^{\gamma} \in [0..4095]\\ + R12^{\gamma} \in [0..4095]\\ 
- C_b12^{\gamma} = C_b12\\ + G12^{\gamma} \in [0..4095]\\ 
- C_r12^{\gamma} = C_r12+ B12^{\gamma} \in [0..4095]
 \] \]
  
-Only the luma component is modified by the gamma correction stage.+All three channels are modified by the gamma adjustment stage.
  
 ===== Step 1: UVC gamma transfer function ===== ===== Step 1: UVC gamma transfer function =====
-Gamma correction is applied **only to the luma component** \(Y12\). +Gamma adjustment is applied **independently** to each RGB channel \(R12\), 
-The chroma components \(C_b12\) and \(C_r12\) are passed through unchanged.+\(G12\)and \(B12\) using the **same** transfer function / LUT.
  
-The UVC gamma transfer function is defined in the following document: [[https://wiki.sub2r.com/doku.php/isp:gamma|UVC Gamma Correction Specification]]+The UVC gamma transfer function is defined in the following document: 
 +[[https://wiki.sub2r.com/doku.php/isp:gamma|UVC Gamma Correction Specification]]
  
 No additional interpretation or modification of the transfer function is No additional interpretation or modification of the transfer function is
Line 44: Line 49:
  
 ===== Step 2: LUT-based FPGA implementation ===== ===== Step 2: LUT-based FPGA implementation =====
-For FPGA implementation, the UVC gamma correction shall be realized using a +For FPGA implementation, the UVC gamma adjustment shall be realized using a 
-LUT with **4096 entries**, indexed by the 12-bit luma value.+LUT with **4096 entries**, indexed by the 12-bit channel value.
  
-Each LUT entry maps a 12-bit input luma value to a 12-bit output luma value:+Each LUT entry maps a 12-bit input channel value to a 12-bit output channel 
 +value:
  
 <code> <code>
-Y_in  = i                       // i in range [0..4095] +X_in  = i                       // i in range [0..4095] 
-Y_out = LUT[i]                  // gamma-corrected luma+X_out = LUT[i]                  // gamma-adjusted channel value
 </code> </code>
 +
 +The same LUT instance (same contents) is used for all channels.
  
 ===== Step 3: LUT generation tool ===== ===== Step 3: LUT generation tool =====
 To simplify and standardize LUT generation, the following online tool may be To simplify and standardize LUT generation, the following online tool may be
-used: [[https://toolbox.sub2r.com/sub2r-tb-gamma.html|Sub2r Gamma LUT Generator]]+used: 
 +[[https://toolbox.sub2r.com/sub2r-tb-gamma.html|Sub2r Gamma LUT Generator]]
  
 The tool generates FPGA-ready gamma tables compatible with a 12-bit input and The tool generates FPGA-ready gamma tables compatible with a 12-bit input and
Line 65: Line 74:
  
 \[ \[
-Y12^{\gamma}  = LUT[Y12]\\ +R12^{\gamma} = LUT[R12]\\ 
-C_b12^{\gamma} = C_b12\\ +G12^{\gamma} = LUT[G12]\\ 
-C_r12^{\gamma} = C_r12+B12^{\gamma} = LUT[B12]
 \] \]
  
Line 73: Line 82:
 bounds. bounds.
  
-===== Notes ===== +===== Integration notes ===== 
-This block operates entirely in **YCbCr space**. +This block is placed as follows:
-* Gamma correction is applied **only to luma**. +
-* Chroma components are passed through unchanged. +
-* The LUT-based design ensures deterministic, low-latency FPGA implementation. +
-* This stage assumes **full-range (computer-range) YCbCr** coding.+
  
 +<code>
 +... -> CMX -> RGB UVC Gamma -> RGB-to-YCbCr -> ...
 +</code>
 +
 +The downstream RGB-to-YCbCr block consumes \(R12^{\gamma}\), \(G12^{\gamma}\),
 +and \(B12^{\gamma}\) as its inputs.
 +
 +{{:isp:screenshot_2026-01-27_063531.png?400|}}
 +
 +===== Expected results =====
 +   * Gamma \(1.0\) is an identity gamma, that produces a LUT of a linear set of incremental values with one-to-one correspondence between input and output
 +   * Image doesn't get washed out too much when Gamma is increased (within the \(1.0\)-\(2.5\) range)
 +   * Slight hue drift is expected, but not to be an excessive one at extreme Gamma values
 +   * LUT table for a given Gamma should match the one produced by the [[https://toolbox.sub2r.com/sub2r-tb-gamma.html|online tool]]
 +
 +===== Notes =====
 +   * This block operates entirely in **RGB space**.
 +   * Gamma adjustment is applied independently to **all three channels** using the **same** LUT (baseline implementation).
 +   * This stage assumes **full-range (computer-range) 12-bit RGB** coding.
  

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also, you acknowledge that you have read and understand our Privacy Policy. If you do not agree, please leave the website.

More information