class: center, middle, title-slide .title[ # Histogram Equalization ] .subtitle[ ## Applications in Computer Vision ] .author[ ### Rozenn Dahyot ] .institute[ ###
] --- ## Introduction - Optimal Transport solution in 1D - Histogram Equalisation - Application to Image contrast enhancement - Exercises --- ## Optimal Transport 1D solution Consider two PDFs `\(f\)` and `\(g\)` and their CDFs noted `\(F\)` (with `\(dF(x)=f(x)\ dx\)`) and `\(G\)` (with `\(dG(x)=g(x)\ dx\)`) respectively, for random variables `\(x\)` and `\(y\)`. **Problem:** How to find a (bijective and differentiable) transformation `\(\phi\)` such that `\(y=\phi(x)\)` for two random variables `\(x\sim f(x)\)` and `\(y \sim g(y)\)`? **Solution:** $$ \phi(x)=G^{-1}\circ F(x) $$ **Example Equalization:** In this case `\(g\equiv \mathcal{U}\)` (uniform) then implying `\(G=Id\)` (identity function) and so `\(G^{-1}=Id\)` leading to the solution `$$\phi(x)=F(x)$$` --- ## Optimal Transport 1D solution ![Histogram Equalisation as a special case of Monge Problem](data:image/png;base64,#images/MU_CS410_OT_HistEq.svg) <!-- https://www.math.cmu.edu/~mthorpe/OTNotes --> --- ## Application to Histogram Equalization <!-- https://www.geeksforgeeks.org/histogram-equalization-using-r-language/ --> Consider the following gray level image of *boats*. We note this image `\(I\)` and its pixel intensity values `\(x\)`. ![](data:image/png;base64,#Slides_HistogramEqualisation_files/figure-html/unnamed-chunk-1-1.png)<!-- --> --- ## Application to Histogram Equalization The Cumulative Distribution Function `\(F(x)=\int_{-\infty}^x f(t) \ dt\)` can be computed. ![](data:image/png;base64,#Slides_HistogramEqualisation_files/figure-html/unnamed-chunk-2-1.png)<!-- --> --- ## Application to Histogram Equalization .pull-left[Each pixel intensity value `\(x\)` is changed to `\(\tilde{x}=\phi(x)\)` using the CDF `\(F\)` with $$ \phi(x)=Id^{-1}\circ F(x) = F(x) $$ ( `\(G=Id\)` is the CDF associated with the Uniform distribution). ] .pull-right[ ![](data:image/png;base64,#Slides_HistogramEqualisation_files/figure-html/unnamed-chunk-3-1.png)<!-- --> ] --- ## Application to Histogram Equalization .pull-left[ ![](data:image/png;base64,#Slides_HistogramEqualisation_files/figure-html/unnamed-chunk-4-1.png)<!-- --> ] .pull-right[ ![](data:image/png;base64,#Slides_HistogramEqualisation_files/figure-html/unnamed-chunk-5-1.png)<!-- --> ] --- ## Application to Histogram Equalization The histogram of the transformed image `\(\tilde{I}\)` is uniform as expected for PDF `\(g\equiv\mathcal{U}\)` that we have chosen when using mapping solution `\(\phi(x)=F(x)\)` ! ![](data:image/png;base64,#Slides_HistogramEqualisation_files/figure-html/unnamed-chunk-6-1.png)<!-- --> --- ## Application to Histogram Equalization Compare with the histogram of the original image *boats* ![](data:image/png;base64,#Slides_HistogramEqualisation_files/figure-html/unnamed-chunk-7-1.png)<!-- --> --- ## Exercises 1. Draw the uniform probability density function (PDF) `\(g\)` on the range of pixel intensity value [0;255]. 1. Draw the CDF `\(G\)` associated with PDF `\(g\)` defined previously. 1. Consider the Logistic function `\(F(x)=\frac{1}{1+\exp(-x)}\)`: is that a possible CDF for a r.v. `\(x\in \mathbb{R}\)`? 1. What is the derivative `\(f\)` of `\(F\)` defined above? Is that a PDF? 1. Suggest how histogram equalization could be applied to colour images? Explain