Camera Post-Processing Pipeline Kari Pulli Senior Director
Total Page:16
File Type:pdf, Size:1020Kb
Camera Post-Processing Pipeline Kari Pulli Senior Director NVIDIANVIDIA Research Research Topics Filtering blurring sharpening bilateral filter Sensor imperfections (PNU, dark current, vignetting, …) ISO (analog – digital conversion with amplification) Demosaicking and denoising Gamma correction Color spaces Response curve White balance JPEG compression NVIDIA Research What is image filtering? Modify the pixels in an image based on some function of a local neighborhood of the pixels 10 5 3 Some function 4 5 1 7 1 1 7 Local image data Modified image data NVIDIA Research Linear functions Simplest: linear filtering replace each pixel by a linear combination of its neighbors The prescription for the linear combination is called the “convolution kernel” 10 5 3 0 0 0 4 5 1 0 0.5 0 7 1 1 7 0 1 0.5 Local image data kernel Modified image data NVIDIA Research Convolution f [m,n] = I ⊗ g = ∑I[m −k,n −l]g[k,l] k,l I NVIDIA Research NVIDIA Research NVIDIA Linear filtering (warm-up slide) original Pixel offset coefficient 1.0 0 ? NVIDIA Research NVIDIA Linear filtering (warm-up slide) original Pixel offset coefficient 1.0 0 (no change) Filtered NVIDIA Research NVIDIA Linear filtering original Pixel offset coefficient 0 1.0 ? NVIDIA Research NVIDIA Shift original Pixel offset coefficient 0 1.0 shifted NVIDIA Research NVIDIA Linear filtering original Pixel offset coefficient 0.3 0 ? NVIDIA Research NVIDIA Blurring original Pixel offset coefficient 0.3 0 both dimensions) (filter applied in blurred impulse NVIDIA Research NVIDIA Blur examples original 8 Pixel offset coefficient 0.3 0 filtered 2.4 edge impulse NVIDIA Research NVIDIA Blur examples 8 original original 8 4 Pixel offset Pixel offset coefficient coefficient 0.3 0.3 0 0 8 filtered 2.4 filtered 4 Linear filtering (warm-up slide) 2.0 1.0 ? 0 0 original NVIDIA Research Linear filtering (no change) 2.0 1.0 0 0 original Filtered (no change) NVIDIA Research Linear filtering 2.0 0.33 ? 0 0 original NVIDIA Research NVIDIA Research NVIDIA (remember blurring) original Pixel offset coefficient 0.3 0 both dimensions) (filter applied in Blurred Sharpening 2.0 0.33 0 0 original Sharpened original NVIDIA Research Sharpening example 1.7 11.2 t n 8 e 8 i c i f f e o c -0.25 -0.3 original sharpened (differences are accentuated; constant areas are left untouched) NVIDIA Research Sharpening before after NVIDIA Research Bilateral filter Tomasi and Manduchi 1998 http://www.cse.ucsc.edu/~manduchi/Papers/ICCV98.pdf Related to SUSAN filter [Smith and Brady 95] http://citeseer.ist.psu.edu/smith95susan.html Digital-TV [Chan, Osher and Chen 2001] http://citeseer.ist.psu.edu/chan01digital.html sigma filter http://www.geogr.ku.dk/CHIPS/Manual/f187.htm NVIDIA Research Start with Gaussian filtering Here, input is a step function + noise J = f ⊗ I output input NVIDIA Research Start with Gaussian filtering Spatial Gaussian f J = f ⊗ I output input NVIDIA Research Start with Gaussian filtering Output is blurred J = f ⊗ I output input NVIDIA Research The problem of edges Weight f(x, ξ) depends on distance from ξ to x Here, I(ξ) “pollutes” our estimate J(x) It is too different J (x) = ∑ f (x,ξ) I(ξ) ξ I ( x) x I ( ξ ) output input NVIDIA Research Principle of Bilateral filtering [Tomasi and Manduchi 1998] Penalty g on the intensity difference 1 J (x) = ∑ f (x,ξ) g(I(ξ) − I(x)) I(ξ) k(x) ξ x I(x) I(ξ ) output input NVIDIA Research Bilateral filtering [Tomasi and Manduchi 1998] Spatial Gaussian f 1 J (x) = ∑ f (x,ξ) g(I(ξ) − I(x)) I(ξ) k(x) ξ x output input NVIDIA Research Bilateral filtering [Tomasi and Manduchi 1998] Spatial Gaussian f Gaussian g on the intensity difference 1 J (x) = ∑ f (x,ξ) g(I(ξ) − I(x)) I(ξ) k(x) ξ x output input NVIDIA Research Normalization factor [Tomasi and Manduchi 1998] k(x) = ∑ f (x,ξ) g(I(ξ) − I(x)) ξ 1 J (x) = ∑ f (x,ξ) g(I(ξ) − I(x)) I(ξ) k(x) ξ x output input NVIDIA Research Bilateral filtering is non-linear [Tomasi and Manduchi 1998] The weights are different for each output pixel 1 J (x) = ∑ f (x,ξ) g(I(ξ) − I(x)) I(ξ) k(x) ξ x x output input NVIDIA Research Other view The bilateral filter uses the 3D distance NVIDIA Research NVIDIA Research From “raw-raw” to RAW Pixel Non-Uniformity each pixel in a CCD has a slightly different sensitivity to light, typically within 1% to 2% of the average signal can be reduced by calibrating an image with a flat-field image flat-field images are also used to eliminate the effects of vignetting and other optical variations Stuck pixels some pixels are turned always on or off identify, replace with filtered values Dark floor temperature adds noise sensors usually have a ring of covered pixels around the exposed sensor, subtract their signal NVIDIA Research ISO = amplification in AD conversion Sensor converts the continuous light signal to a continuous electrical signal The analog signal is converted to a digital signal at least 10 bits (even on cell phones), often 12 or more (roughly) linear sensor response Before conversion the signal can be amplified ISO 100 means no amplification ISO 1600 means 16x amplification +: can see details in dark areas better -: noise is amplified as well; sensor more likely to saturate NVIDIA Research ISO NVIDIA Research But too dark signal needs amplification With too little light, and a given desired image brightness, two alternatives use low ISO and brighten digitally amplifies also post-gain noise (e.g., read noise) use high ISO to get brightness directly a bit less noise But both amplification choices amplify noise ideally, you make sure the signal is high by using a slower exposure or larger aperture NVIDIA Research Demosaicking or Demosaicing? NVIDIA Research Demosaicking NVIDIA Research Your eyes does it too… NVIDIA Research Demosaicking NVIDIA Research First choice: bilinear interpolation Easy to implement But fails at sharp edges NVIDIA Research Two-color sampling of BW edge Luminance profile True full-color image Sampled data Linear interpolation NVIDIA Research Typical color Moire patterns Blow-up of electronic camera image. Notice spurious colors in the regions of fine detail in the plants. NVIDIA Research Brewster’s colors — evidence of interpolation from spatially offset color samples Scale relative to human photoreceptor size: each line covers about 7 photoreceptors. NVIDIA Research Color sampling artifacts NVIDIA Research R-G, after linear interpolation NVIDIA Research Median filter Replace each pixel by the median over N pixels (5 pixels, for these examples). Generalizes to “rank order” filters. In: Out: Spike noise is removed 5-pixel neighborhood Monotonic edges In: Out: remain unchanged NVIDIA Research Degraded image NVIDIA Research Radius 1 median filter NVIDIA Research Radius 2 median filter NVIDIA Research R – G NVIDIA Research R – G, median filtered (5x5) NVIDIA Research Two-color sampling of BW edge Sampled data Linear interpolation Color difference signal Median filtered color difference signal Reconstructed pixel values NVIDIA Research Recombining the median filtered colors Linear interpolation Median filter interpolation NVIDIA Research Take edges into account Use bilateral filtering ADAPTIVE DEMOSAICKING avoid interpolating across edges Ramanath, Snyder, JEI 2003 NVIDIA Research Take edges into account HIGH-QUALITY LINEAR INTERPOLATION FOR DEMOSAICING OF BAYER-PATTERNED COLOR IMAGES Malvar, He, Cutler, ICASSP 2004 Predict edges and adjust assumptions luminance correlates with RGB edges = luminance change When estimating G at R if the R differs from bilinearly estimated R luminance changes Correct the bilinear estimate by the difference between the estimate and real value NVIDIA Research Joint Demosaicing and Denoising Denoising in ISP? Hirakawa, Parks, IEEE TIP 2006 The experimental results confirm that the proposed method suppresses noise (CMOS/CCD image sensor noise model) while effectively interpolating the missing pixel components, demonstrating a significant improvement in image quality when compared to treating demosaicking and denoising problems independently. NVIDIA Research Denoising using non-local means Most image details occur repeatedly Each color indicates a group of squares in the image which are almost indistinguishable Image self-similarity can be used to eliminate noise it suffices to average the squares which resemble each other Image and movie denoising by nonlocal means Buades, Coll, Morel, IJCV 2006 NVIDIA Research Restoring a highly compressed image NL-means is able to remove block artifacts due to compression but at the cost of removing some details, as the difference between the compressed and restored image shows NVIDIA Research BM3D (Block Matching 3D) NVIDIA Research How many bits are needed for smooth shading? With a given adaptation, human vision has contrast sensitivity ~1% call black 1, white 100 you can see differences 1, 1.01, 1.02, … needed step size ~ 0.01 98, 99, 100 needed step size ~ 1 with linear encoding delta 0.01 – 100 steps between 99 & 100 wasteful delta 1 – only 1 step between 1 & 2 lose detail in shadows instead, apply a non-linear power function, gamma provides adaptive step size NVIDIA Research 61 Gamma encoding With 6 bits available (for illustration below) for encoding linear loses detail in the dark end Raise intensity X to power Xγ where γ = 1/2.2 then encode Display applies γ = 2.5 to get back to linear light the difference boosts colors to compensate for a dark viewing environment NVIDIA Research 62 Gamma on displays 1 CRT inherent gamma of ~2.35 – 2.55 0 1 due to electrostatics of the cathode and electron gun just a coincidence that