From 6b102d793b660cc1cdffd12d10ded50e20e2fc0d Mon Sep 17 00:00:00 2001
From: Manuel Grizonnet <manuel.grizonnet@cnes.fr>
Date: Thu, 21 Dec 2017 15:52:33 +0100
Subject: [PATCH] DOC: review contrast enhancement application

---
 Documentation/Cookbook/rst/Recipes.rst        |   5 +-
 .../rst/recipes/contrast_enhancement.rst      | 108 +++++++++---------
 2 files changed, 59 insertions(+), 54 deletions(-)

diff --git a/Documentation/Cookbook/rst/Recipes.rst b/Documentation/Cookbook/rst/Recipes.rst
index d925306170..18cab29de9 100644
--- a/Documentation/Cookbook/rst/Recipes.rst
+++ b/Documentation/Cookbook/rst/Recipes.rst
@@ -13,8 +13,9 @@ and demonstrate how the can be applied.
    recipes/sarprocessing.rst
    recipes/residual_registration.rst
    recipes/improc.rst
+   recipes/bandmathx.rst
+   recipes/contrast_enhancement.rst
    recipes/pbclassif.rst
    recipes/featextract.rst
    recipes/stereo.rst
-   recipes/bandmathx.rst
-   recipes/contrast_enhancement.rst
+   
diff --git a/Documentation/Cookbook/rst/recipes/contrast_enhancement.rst b/Documentation/Cookbook/rst/recipes/contrast_enhancement.rst
index 8365e3a45e..79273a1b8d 100644
--- a/Documentation/Cookbook/rst/recipes/contrast_enhancement.rst
+++ b/Documentation/Cookbook/rst/recipes/contrast_enhancement.rst
@@ -1,82 +1,87 @@
-Visual product and contrast enhancement
-========================================================
-Sensor images have often a wide dynamic range. Whereas it is very helpful
-to have high precision to do complex processing, it is pretty hard to display
-high dynamic images, even on modern screen. The dynamic range for basic
-screen is of 8 bits. Images can contain 12 or 16 bits (or even more!) of data.
+Enhance local contrast
+======================
 
+Principles
+~~~~~~~~~~
+
+Sensor images have often a wide dynamic range. Whereas it is helpful to have
+high precision to do complex processing, it is pretty hard to display high
+dynamic images, even on modern screen as the dynamic range for basic screen is
+of 8 bits while images can be encoded on 12 or 16 bits (or even more!).
+
+.. _Figure1:
+      
 |image5| |image6|
 
-The contrast enhancement application is aiming at reducing this dynamic
-by reorganizing it in a smarter way than just linear compression.
-In a linear compression, compression changes the dynamic range (for instance
-from 12 to 8 bits) but does not change the repartition of the pixel.
+The *ContrastEnhancement* application aims to reduce the image dynamic by
+reorganizing it in a smarter way than just linear compression and improve the
+local contrast and enhance the definitions of edges.
+
+.. _Figure2:
 
 |image1| |image2|
 
-Here the equalization of histogram is creating a look up table in order to
-maximize the use of dynamic. The target histogram is a perfectly flat one.
-The gain applied on each pixel comes from the computation of the transfer
-function :math:`T` such that :
+The equalization of histogram creates a look up table in order to maximize the
+dynamic. The target histogram is perfectly flat.  The gain applied on each pixel
+comes from the computation of the transfer function :math:`T` such that :
 
-.. math:: \forall i \quad  \int_{min}^{i*T(i)}h_{istogram}(j)dj = 
+.. math:: \forall i \quad \int_{min}^{i*T(i)}h_{istogram}(j)dj =
           \int_{min}^{i}h_{target}(j)dj
 
-where :math:`h_{target}` is the corresponding flat histogram and we have
-the constraint that white and black are still white and black after
-equalization : 
+where :math:`h_{target}` is the corresponding flat histogram with the constraint
+that white and black are still white and black after equalization :
 
 .. math:: T(min) = T(max) = 1
 
-With this in mind you can then try it on your own images with the simple
-following use :
+You can apply this transformation with the *ContrastEnhancement* application:
 
-:: 
+::
 
-    otbcli_ContrastEnhancement -in input_image.tif 
-                               -out output_image.tif 
+    otbcli_ContrastEnhancement -in input_image.tif
+                               -out output_image.tif
                                -spatial global
 
-You can then compress your dynamic without loosing too much detail and
-contrast.
+It allows to compress the dynamic without loosing details and contrast.
 
 Advanced parameters
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-You can see that more parameters are available in the application. Let us see
-what there are for.
-First what you want to equalize. There are two modes :
-* luminance : you provide the application with a 3 bands image and the
-equalization will be done on a single band which will be a composition of
-the original bands. The computed gain will then be applied on the different
-bands. The classical use of this method is to conserve ratio between the
-different color, conserve the hue.
-* channel : you provide the application with a n bands image and each of
-them are equalized independently.
-
-The other option is the local equalization. You can choose a window size
-that will be use to split the image in tiles and histograms will be
-computed over those tiles. Gain will be interpolated between the adjacent
-tiles in order to give a smooth result.
+~~~~~~~~~~~~~~~~~~~
+
+The *ContrastEnhancement* provides different options to configure the contrast
+enhancement method. Let us see what there are for.
+
+First what you want to equalize. Two modes are available:
+
+* **luminance:** on 3 bands image, the equalization will be done on a single
+  band which will be a composition of the original bands. The computed gain will
+  then be applied on the different bands. The classical use of this method is to
+  conserve ratio between the different color, conserve the hue.
+* **channel:** each bands are equalized independently.
+
+The other option is the local equalization. You can choose a window size that
+will be use to split the image in tiles and histograms will be computed over
+those tiles. Gain will be interpolated between the adjacent tiles in order to
+give a smooth result.
 
 ::
 
     otbcli_ContrastEnhancement -in input_image.tif
-                               -out output_image.tif
-                               -spatial.local.h 500
+                               -out output_image.tif spatial.local.h 500
                                -spatial.local.w 500
                                -mode lum
 
-The application also offers a way to limit contrast by adjusting original
-histogram. The limitation factor represent the limit height that can have
-any bucket of the histogram : we compute the height of the perfect flat
-histogram and the maximal height is the limitation factor time this "flat
-height".
+The *ContrastEnhancement* application also offers a way to limit contrast by
+adjusting original histogram with the **hfact** parameter. The limitation factor
+represents the limit height that can have any bucket of the histogram; the
+application computes the height of the flat histogram and the maximal height is
+the limitation factor time this "flat height".
+
+.. _Figure3:
 
 |image4|
 
-Finally you have the choice to ignore a particular value with the "nodata"
-parameter, and also the choice to put manually your minimum and maximum value,
-which can be a gain of time. Any value out of bound will be ignored.
+Finally, you can ignore a particular value with the **nodata** parameter, and
+also set manually your minimum and maximum value. Any value out of bound will be
+ignored.
 
 
 .. |image1| image:: ../Art/contrast1.png
@@ -91,7 +96,6 @@ which can be a gain of time. Any value out of bound will be ignored.
             :scale: 30%
             :alt: original
 
-
 .. |image6| image:: ../Art/contrast_result.jpg
             :scale: 30%
             :alt: result
-- 
GitLab