diff --git a/Documentation/Cookbook/Art/contrast1.png b/Documentation/Cookbook/Art/contrast1.png index 67f59ebe02f87e91d727f5346b7f79144ba9955a..614c9f00c9e6c905ccbe6995464a4e6531863b8c 100644 Binary files a/Documentation/Cookbook/Art/contrast1.png and b/Documentation/Cookbook/Art/contrast1.png differ diff --git a/Documentation/Cookbook/Art/contrast2.png b/Documentation/Cookbook/Art/contrast2.png index 2da8172f7c538218655f8c0f03b080a3173be628..39deef978d7fb2f1faa2452c2d9c5e1077a999a6 100644 Binary files a/Documentation/Cookbook/Art/contrast2.png and b/Documentation/Cookbook/Art/contrast2.png differ diff --git a/Documentation/Cookbook/Art/contrast3.png b/Documentation/Cookbook/Art/contrast3.png index f255cd8a8a8bd24aacdcf62512b6cc2956596564..2b622298496cba84cf7e8a4868d52cf8444cb0ad 100644 Binary files a/Documentation/Cookbook/Art/contrast3.png and b/Documentation/Cookbook/Art/contrast3.png differ diff --git a/Documentation/Cookbook/Art/contrast4.png b/Documentation/Cookbook/Art/contrast4.png index 6633b21cff7bc3f51d18da8b50cd28743011a6c2..93eb1b67af7b2e1e040343d72e4cd8dd17961a17 100644 Binary files a/Documentation/Cookbook/Art/contrast4.png and b/Documentation/Cookbook/Art/contrast4.png differ diff --git a/Documentation/Cookbook/rst/Recipes.rst b/Documentation/Cookbook/rst/Recipes.rst index fa9478d5abf7698b4abbdcf806d625a0ab220cba..d92530617047b368dddffd8fad0746dc1e643f08 100644 --- a/Documentation/Cookbook/rst/Recipes.rst +++ b/Documentation/Cookbook/rst/Recipes.rst @@ -17,3 +17,4 @@ and demonstrate how the can be applied. 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 2998a91745d747a03274160e9dfc8ce8fd7cee72..0fe5d4ce06c5a3e7713c9fd32a87b5decc265002 100644 --- a/Documentation/Cookbook/rst/recipes/contrast_enhancement.rst +++ b/Documentation/Cookbook/rst/recipes/contrast_enhancement.rst @@ -8,21 +8,28 @@ The contrast enhancement application is aiming at reducing this dynamic by compressing 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. + |image1| |image2| -.. |image1| image:: ../Art/contrast1.png +Here the equalization of histogram is creating a look up table in order to +maximize the use of dynamics. The target histogram is perfectly flat one. +The gain applied on each pixel comes from the computation of the transfer +function :math:`T` such that : -.. |image2| image:: ../Art/contrast2.png +.. math:: \forall i \quad \int_{min}^{i*T(i)}h_{istogram}(j)dj = + \int_{min}^{i}h_{target}(j)dj -Here the equalization of histogram is creating a look up table in order to -maximize the use of dynamics. +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 : -..image::../Art/contrast3.png +.. math:: T(min) = T(max) = 1 With this in mind you can then try it on your own images with the simple following use : -:: +:: + otbcli_ContrastEnhancement -in input_image.tif -out output_image.tif -spatial global @@ -46,10 +53,11 @@ 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 - -spatial.local.w 500 + + otbcli_ContrastEnhancement -in input_image.tif + -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 @@ -58,9 +66,19 @@ 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". -..image::../Art/contrast4.png +|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. Any value out of bound will be ignored. +.. |image1| image:: ../Art/contrast1.png + :scale: 30% + +.. |image2| image:: ../Art/contrast2.png + :scale: 30% + +.. |image3| image:: ../Art/contrast3.png + :scale: 40% + +.. |image4| image:: ../Art/contrast4.png \ No newline at end of file