<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://rawpedia.rawtherapee.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Sguyader</id>
	<title>RawPedia - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://rawpedia.rawtherapee.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Sguyader"/>
	<link rel="alternate" type="text/html" href="http://rawpedia.rawtherapee.com/Special:Contributions/Sguyader"/>
	<updated>2026-04-21T18:16:02Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.38.4</generator>
	<entry>
		<id>http://rawpedia.rawtherapee.com/index.php?title=Favorites_Tab&amp;diff=5016</id>
		<title>Favorites Tab</title>
		<link rel="alternate" type="text/html" href="http://rawpedia.rawtherapee.com/index.php?title=Favorites_Tab&amp;diff=5016"/>
		<updated>2019-03-28T13:07:46Z</updated>

		<summary type="html">&lt;p&gt;Sguyader: Corrected a typo: &amp;quot;Favorites&amp;quot; is in plural in the options file&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
RawTherapee 5.6 introduced a new &amp;quot;Favorites&amp;quot; tab, which allows you to list your favorite tools for quick access. Tools listed in the Favorites tab are removed from their tabs of origin.&lt;br /&gt;
&lt;br /&gt;
The Favorites tab is hidden by default, and appears when tools are added to it.&lt;br /&gt;
&lt;br /&gt;
A graphical user interface for easily marking tools as &amp;quot;favorited&amp;quot; is being worked on, but due to time constraints related to the release date, this GUI is not ready for 5.6 and will feature in a future release. For the time being, users who wish to &amp;quot;favorite&amp;quot; specific tools need to do so manually, as described below.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
To add a tool to the Favorites tab:&lt;br /&gt;
# Edit the &amp;lt;code&amp;gt;[[File Paths|options]]&amp;lt;/code&amp;gt; file in a text editor.&lt;br /&gt;
# Locate the &amp;lt;code&amp;gt;Favorites=&amp;lt;/code&amp;gt; key in the &amp;lt;code&amp;gt;GUI&amp;lt;/code&amp;gt; section.&lt;br /&gt;
# Add tools by their code-name (listed below), separated by a semicolon and ending with a semicolon. They appear in the order in which they are listed in the key. For example, to add Exposure, Shadows/Highlights and Resize to the Favorites tab, set the key as follows: &amp;lt;code&amp;gt;Favorites=tonecurve;shadowshighlights;resize;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Tool code-names:&lt;br /&gt;
&lt;br /&gt;
* Exposure&lt;br /&gt;
** Exposure - &amp;lt;code&amp;gt;tonecurve&amp;lt;/code&amp;gt;&lt;br /&gt;
** Shadows/Highlights - &amp;lt;code&amp;gt;shadowshighlights&amp;lt;/code&amp;gt;&lt;br /&gt;
** Tone Mapping - &amp;lt;code&amp;gt;epd&amp;lt;/code&amp;gt;&lt;br /&gt;
** Dynamic Range Compression - &amp;lt;code&amp;gt;fattal&amp;lt;/code&amp;gt;&lt;br /&gt;
** Vignette Filter - &amp;lt;code&amp;gt;pcvignette&amp;lt;/code&amp;gt;&lt;br /&gt;
** Graduated Filter - &amp;lt;code&amp;gt;gradient&amp;lt;/code&amp;gt;&lt;br /&gt;
** L*a*b* Adjustments - &amp;lt;code&amp;gt;labcurves&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Detail&lt;br /&gt;
** Sharpening - &amp;lt;code&amp;gt;sharpening&amp;lt;/code&amp;gt;&lt;br /&gt;
** Local Contrast - &amp;lt;code&amp;gt;localcontrast&amp;lt;/code&amp;gt;&lt;br /&gt;
** Edges - &amp;lt;code&amp;gt;sharpenedge&amp;lt;/code&amp;gt;&lt;br /&gt;
** Microcontrast - &amp;lt;code&amp;gt;sharpenmicro&amp;lt;/code&amp;gt;&lt;br /&gt;
** Impulse Noise Reduction - &amp;lt;code&amp;gt;impulsedenoise&amp;lt;/code&amp;gt;&lt;br /&gt;
** Noise Reduction - &amp;lt;code&amp;gt;dirpyrdenoise&amp;lt;/code&amp;gt;&lt;br /&gt;
** Defringe - &amp;lt;code&amp;gt;defringe&amp;lt;/code&amp;gt;&lt;br /&gt;
** Contrast by Detail Levels - &amp;lt;code&amp;gt;dirpyrequalizer&amp;lt;/code&amp;gt;&lt;br /&gt;
** Haze Removal - &amp;lt;code&amp;gt;dehaze&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Color&lt;br /&gt;
** White Balance - &amp;lt;code&amp;gt;whitebalance&amp;lt;/code&amp;gt;&lt;br /&gt;
** Vibrance - &amp;lt;code&amp;gt;vibrance&amp;lt;/code&amp;gt;&lt;br /&gt;
** Channel Mixer - &amp;lt;code&amp;gt;chmixer&amp;lt;/code&amp;gt;&lt;br /&gt;
** Black-and-White - &amp;lt;code&amp;gt;blackwhite&amp;lt;/code&amp;gt;&lt;br /&gt;
** HSV Equalizer - &amp;lt;code&amp;gt;hsvequalizer&amp;lt;/code&amp;gt;&lt;br /&gt;
** Film Simulation - &amp;lt;code&amp;gt;filmsimulation&amp;lt;/code&amp;gt;&lt;br /&gt;
** Soft Light - &amp;lt;code&amp;gt;softlight&amp;lt;/code&amp;gt;&lt;br /&gt;
** RGB Curves - &amp;lt;code&amp;gt;rgbcurves&amp;lt;/code&amp;gt;&lt;br /&gt;
** Color Toning - &amp;lt;code&amp;gt;colortoning&amp;lt;/code&amp;gt;&lt;br /&gt;
** Color Management - &amp;lt;code&amp;gt;icm&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Advanced&lt;br /&gt;
*** Retinex - &amp;lt;code&amp;gt;retinex&amp;lt;/code&amp;gt;&lt;br /&gt;
*** Wavelet Levels - &amp;lt;code&amp;gt;wavelet&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Transform&lt;br /&gt;
** Crop - &amp;lt;code&amp;gt;crop&amp;lt;/code&amp;gt;&lt;br /&gt;
** Resize - &amp;lt;code&amp;gt;resize&amp;lt;/code&amp;gt;&lt;br /&gt;
*** Post-Resize Sharpening - &amp;lt;code&amp;gt;prsharpening&amp;lt;/code&amp;gt;&lt;br /&gt;
** Lens / Geometry - &amp;lt;code&amp;gt;lensgeom&amp;lt;/code&amp;gt;&lt;br /&gt;
*** Rotate - &amp;lt;code&amp;gt;rotate&amp;lt;/code&amp;gt;&lt;br /&gt;
*** Perspective - &amp;lt;code&amp;gt;perspective&amp;lt;/code&amp;gt;&lt;br /&gt;
*** Profiled Lens Correction - &amp;lt;code&amp;gt;lensprof&amp;lt;/code&amp;gt;&lt;br /&gt;
*** Distortion Correction - &amp;lt;code&amp;gt;distortion&amp;lt;/code&amp;gt;&lt;br /&gt;
*** Chromatic Aberration Correction - &amp;lt;code&amp;gt;cacorrection&amp;lt;/code&amp;gt;&lt;br /&gt;
*** Vignetting Correction - &amp;lt;code&amp;gt;vignetting&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Raw&lt;br /&gt;
** Sensor with Bayer Matrix - &amp;lt;code&amp;gt;sensorbayer&amp;lt;/code&amp;gt;&lt;br /&gt;
*** Demosaicing - &amp;lt;code&amp;gt;bayerprocess&amp;lt;/code&amp;gt;&lt;br /&gt;
*** Raw Black Points - &amp;lt;code&amp;gt;bayerrawexposure&amp;lt;/code&amp;gt;&lt;br /&gt;
*** Preprocessing - &amp;lt;code&amp;gt;bayerpreprocess&amp;lt;/code&amp;gt;&lt;br /&gt;
*** Chromatic Aberration - &amp;lt;code&amp;gt;rawcacorrection&amp;lt;/code&amp;gt;&lt;br /&gt;
** Sensor with X-Trans Matrix - &amp;lt;code&amp;gt;sensorxtrans&amp;lt;/code&amp;gt;&lt;br /&gt;
*** Demosaicing - &amp;lt;code&amp;gt;xtransprocess&amp;lt;/code&amp;gt;&lt;br /&gt;
*** Raw Black Points - &amp;lt;code&amp;gt;xtransrawexposure&amp;lt;/code&amp;gt;&lt;br /&gt;
** Dark-Frame - &amp;lt;code&amp;gt;darkframe&amp;lt;/code&amp;gt;&lt;br /&gt;
** Flat-Field - &amp;lt;code&amp;gt;flatfield&amp;lt;/code&amp;gt;&lt;br /&gt;
** Raw White Points - &amp;lt;code&amp;gt;rawexposure&amp;lt;/code&amp;gt;&lt;br /&gt;
** Preprocessing - &amp;lt;code&amp;gt;preprocess&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sguyader</name></author>
	</entry>
	<entry>
		<id>http://rawpedia.rawtherapee.com/index.php?title=Windows&amp;diff=3514</id>
		<title>Windows</title>
		<link rel="alternate" type="text/html" href="http://rawpedia.rawtherapee.com/index.php?title=Windows&amp;diff=3514"/>
		<updated>2018-01-25T13:44:33Z</updated>

		<summary type="html">&lt;p&gt;Sguyader: /* Copy RawTherapee and required DLLs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide documents how to build RawTherapee for 32-bit or 64-bit versions of Windows using the MinGW-w64 runtime. Begin by installing and updating MSYS2 using the instructions from the [https://msys2.github.io/ MSYS2 website]. Then run the following commands using either &amp;quot;''MinGW-w64 Win32 Shell''&amp;quot; if you want to build a 32-bit version, or &amp;quot;''MinGW-w64 Win64 Shell''&amp;quot; if you want to build a 64-bit version.&lt;br /&gt;
&lt;br /&gt;
RawTherapee can be built using GTK+ versions 2 or 3. To build using GTK2 use the &amp;lt;code&amp;gt;gtk2&amp;lt;/code&amp;gt; branch; to build using GTK3 use the &amp;lt;code&amp;gt;dev&amp;lt;/code&amp;gt; branch. The last version of RawTherapee to support GTK2 is 5.0-r1-gtk2 released on 2017-02-02. Use the &amp;lt;code&amp;gt;dev&amp;lt;/code&amp;gt; branch for the latest code - it requires GTK+ &amp;gt;=3.16. We recommend using GTK+ 3.22.24 or newer as this is the first version to support native windows, without which the RawTherapee window could exhibit [https://github.com/Beep6581/RawTherapee/issues/4125 strange behavior] such as maximizing under the taskbar in Windows 10.&lt;br /&gt;
&lt;br /&gt;
== Install tools and libraries ==&lt;br /&gt;
&lt;br /&gt;
First, install a few miscellaneous tools:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
$ pacman -S tar gzip nano make diffutils intltool git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then install the necessary development tools:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
# win32&lt;br /&gt;
$ pacman -S mingw-w64-i686-gcc mingw-w64-i686-gdb mingw-w64-i686-make mingw-w64-i686-pkg-config mingw-w64-i686-cmake&lt;br /&gt;
# win64&lt;br /&gt;
$ pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-gdb mingw-w64-x86_64-make mingw-w64-x86_64-pkg-config mingw-w64-x86_64-cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and the required libraries:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
# win32&lt;br /&gt;
$ pacman -S mingw-w64-i686-gtkmm mingw-w64-i686-gtkmm3 mingw-w64-i686-lcms2 mingw-w64-i686-fftw&lt;br /&gt;
# win64&lt;br /&gt;
$ pacman -S mingw-w64-x86_64-gtkmm mingw-w64-x86_64-gtkmm3 mingw-w64-x86_64-lcms2 mingw-w64-x86_64-fftw mingw-w64-x86_64-lensfun&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Download and build libiptcdata ==&lt;br /&gt;
&lt;br /&gt;
The libiptcdata library is not yet provided by MSYS2, therefore it should be downloaded and configured using:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
$ curl -LO http://downloads.sourceforge.net/project/libiptcdata/libiptcdata/1.0.4/libiptcdata-1.0.4.tar.gz&lt;br /&gt;
$ tar xzf libiptcdata-1.0.4.tar.gz&lt;br /&gt;
$ cd libiptcdata-1.0.4&lt;br /&gt;
&lt;br /&gt;
# win32&lt;br /&gt;
$ ./configure --prefix=/mingw32&lt;br /&gt;
# win64&lt;br /&gt;
$ ./configure --prefix=/mingw64&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Afterwards the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; needs to be opened using a text editor to remove &amp;lt;code&amp;gt;iptc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;docs&amp;lt;/code&amp;gt; from the lists named &amp;lt;code&amp;gt;SUBDIRS&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;DIST_SUBDIRS&amp;lt;/code&amp;gt;, as building or installing will fail otherwise:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
$ nano Makefile&lt;br /&gt;
&lt;br /&gt;
# Replace&lt;br /&gt;
DIST_SUBDIRS = m4 libiptcdata po iptc docs win python&lt;br /&gt;
# with&lt;br /&gt;
DIST_SUBDIRS = m4 libiptcdata po win python&lt;br /&gt;
&lt;br /&gt;
# And replace&lt;br /&gt;
SUBDIRS = m4 libiptcdata po iptc docs win $(MAYBE_PYTHONLIB)&lt;br /&gt;
# with&lt;br /&gt;
SUBDIRS = m4 libiptcdata po win $(MAYBE_PYTHONLIB)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally build and install the library:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
$ make&lt;br /&gt;
$ make install&lt;br /&gt;
$ cd&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Download and build Clearlooks ==&lt;br /&gt;
&lt;br /&gt;
If you are building RawTherapee using GTK2 then you need the Clearlooks theme engine. You do not need it if you are building using GTK3.&lt;br /&gt;
&lt;br /&gt;
Download and build it:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
$ curl -LO http://sources.archlinux.org/other/gtk-engines/gtk-engines-2.21.0.tar.gz&lt;br /&gt;
$ tar xzf gtk-engines-2.21.0.tar.gz&lt;br /&gt;
$ cd gtk-engines-2.21.0&lt;br /&gt;
&lt;br /&gt;
# win32&lt;br /&gt;
$ ./configure --prefix=/mingw32 --disable-all --enable-clearlooks&lt;br /&gt;
# win64&lt;br /&gt;
$ ./configure --prefix=/mingw64 --disable-all --enable-clearlooks&lt;br /&gt;
&lt;br /&gt;
$ make&lt;br /&gt;
$ make install&lt;br /&gt;
$ cd&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Clone and build RawTherapee ==&lt;br /&gt;
&lt;br /&gt;
Clone RawTherapee's Git repository. The build process will fail if there is a space character anywhere in your &amp;lt;code&amp;gt;build&amp;lt;/code&amp;gt; folder path. For example if your Windows username is &amp;quot;Zank Frappa&amp;quot; then your home path will be &amp;lt;code&amp;gt;C:\Users\Zank Frappa\&amp;lt;/code&amp;gt; and if you clone RawTherapee inside there then the build will fail during compilation. Simply clone to a folder where neither it nor its parent folders have a space in their name, for example &amp;lt;code&amp;gt;C:\code\repo-rt&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
$ git clone http://github.com/Beep6581/RawTherapee.git /c/code/repo-rt&lt;br /&gt;
$ cd /c/code/repo-rt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RawTherapee can be built using GTK+ versions 2 or 3. To build using GTK2 use the &amp;lt;code&amp;gt;gtk2&amp;lt;/code&amp;gt; branch; to build using GTK3 use the &amp;lt;code&amp;gt;dev&amp;lt;/code&amp;gt; branch. The last version of RawTherapee to support GTK2 is 5.0-r1-gtk2 released on 2017-02-02. Use the &amp;lt;code&amp;gt;dev&amp;lt;/code&amp;gt; branch for the latest code - it requires GTK+ &amp;gt;=3.16. When you clone the repository you will automatically find yourself in the &amp;lt;code&amp;gt;dev&amp;lt;/code&amp;gt; branch. To switch to the &amp;lt;code&amp;gt;dev&amp;lt;/code&amp;gt; branch manually, do the following:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
$ git checkout dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a separate directory for the build:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
$ mkdir build&lt;br /&gt;
$ cd build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that if you switch branches then you must delete and recreate the &amp;lt;code&amp;gt;build&amp;lt;/code&amp;gt; folder so that compilation starts from scratch in an empty folder, otherwise compilation is likely to fail. However if you are just updating without changing branches then you do not have to start with an empty build folder - you can just go into the existing one, and compilation will be faster because not everything will need to be recompiled.&lt;br /&gt;
&lt;br /&gt;
Run CMake and Make:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
$ cmake -G &amp;quot;MSYS Makefiles&amp;quot; -DLENSFUNDBDIR=share/lensfun -DCMAKE_BUILD_TYPE=&amp;quot;release&amp;quot; -DPROC_TARGET_NUMBER=&amp;quot;2&amp;quot; -DCACHE_NAME_SUFFIX=&amp;quot;5-dev&amp;quot; ..&lt;br /&gt;
$ make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find an explanation of the various CMake options in the [[Linux#CMake|Linux article]], including an explanation of the various &amp;quot;BUILD_TYPE&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
If you are building for 32-bit Windows XP and are using the &amp;lt;code&amp;gt;release&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;relwithdebinfo&amp;lt;/code&amp;gt; &amp;quot;BUILD_TYPE&amp;quot;, you will need to add the &amp;lt;code&amp;gt;-mstackrealign&amp;lt;/code&amp;gt; compiler flag before the last two dots &amp;lt;code&amp;gt;..&amp;lt;/code&amp;gt; of the CMake command above:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
-DCMAKE_C_FLAGS=&amp;quot;-mstackrealign&amp;quot; -DCMAKE_CXX_FLAGS=&amp;quot;-mstackrealign&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Copy RawTherapee and required DLLs ==&lt;br /&gt;
&lt;br /&gt;
RawTherapee can now be started from the MSYS2 command line:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
# for debug builds&lt;br /&gt;
$ cd debug&lt;br /&gt;
# for release builds&lt;br /&gt;
$ cd release&lt;br /&gt;
# for relwithdebinfo builds&lt;br /&gt;
$ cd relwithdebinfo&lt;br /&gt;
$ ./rawtherapee.exe&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file manager can be used to copy the contents of &amp;lt;code&amp;gt;c:\code\repo-rt\build\&amp;lt;debug|release|relwithdebinfo&amp;gt;&amp;lt;/code&amp;gt; together with the necessary DLLs from &amp;lt;code&amp;gt;&amp;lt;prefix&amp;gt;\bin&amp;lt;/code&amp;gt; into &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt;, where:&lt;br /&gt;
*&amp;lt;code&amp;gt;&amp;lt;prefix&amp;gt;&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;&amp;lt;MSYS2&amp;gt;\&amp;lt;mingw32|mingw64&amp;gt;&amp;lt;/code&amp;gt;,&lt;br /&gt;
*&amp;lt;code&amp;gt;&amp;lt;MSYS2&amp;gt;&amp;lt;/code&amp;gt; is the MSYS2 installation folder,&lt;br /&gt;
*and &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; is the Rawtherapee installation folder.&lt;br /&gt;
&lt;br /&gt;
The current list of required DLLs is:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
libatk-1.0-0.dll&lt;br /&gt;
libatkmm-1.6-1.dll&lt;br /&gt;
libbz2-1.dll&lt;br /&gt;
libcairo-2.dll&lt;br /&gt;
libcairo-gobject-2.dll&lt;br /&gt;
libcairomm-1.0-1.dll&lt;br /&gt;
libcroco-0.6-3.dll&lt;br /&gt;
libepoxy-0.dll&lt;br /&gt;
libexpat-1.dll&lt;br /&gt;
libfﬁ-6.dll&lt;br /&gt;
libfftw3f-3.dll&lt;br /&gt;
libfontconﬁg-1.dll&lt;br /&gt;
libfreetype-6.dll&lt;br /&gt;
libgcc_s_seh-1.dll&lt;br /&gt;
libgdk_pixbuf-2.0-0.dll&lt;br /&gt;
libgdk-3-0.dll&lt;br /&gt;
libgdkmm-3.0-1.dll&lt;br /&gt;
libgio-2.0-0.dll&lt;br /&gt;
libgiomm-2.4-1.dll&lt;br /&gt;
libglib-2.0-0.dll&lt;br /&gt;
libglibmm-2.4-1.dll&lt;br /&gt;
libgmodule-2.0-0.dll&lt;br /&gt;
libgobject-2.0-0.dll&lt;br /&gt;
libgomp-1.dll&lt;br /&gt;
libgraphite2.dll&lt;br /&gt;
libgtk-3-0.dll&lt;br /&gt;
libgtkmm-3.0-1.dll&lt;br /&gt;
libharfbuzz-0.dll&lt;br /&gt;
libiconv-2.dll&lt;br /&gt;
libintl-8.dll&lt;br /&gt;
libjpeg-8.dll&lt;br /&gt;
liblcms2-2.dll&lt;br /&gt;
liblensfun.dll&lt;br /&gt;
liblzma-5.dll&lt;br /&gt;
libpango-1.0-0.dll&lt;br /&gt;
libpangocairo-1.0-0.dll&lt;br /&gt;
libpangoft2-1.0-0.dll&lt;br /&gt;
libpangomm-1.4-1.dll&lt;br /&gt;
libpangowin32-1.0-0.dll&lt;br /&gt;
libpcre-1.dll&lt;br /&gt;
libpixman-1-0.dll&lt;br /&gt;
libpng16-16.dll&lt;br /&gt;
librsvg-2-2.dll&lt;br /&gt;
libsigc-2.0-0.dll&lt;br /&gt;
libstdc++-6.dll&lt;br /&gt;
libsystre-0.dll&lt;br /&gt;
libtiff-5.dll&lt;br /&gt;
libtre-5.dll&lt;br /&gt;
libwinpthread-1.dll&lt;br /&gt;
libxml2-2.dll&lt;br /&gt;
zlib1.dll&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following list of Adwaita theme files should be copied from &amp;lt;code&amp;gt;&amp;lt;prefix&amp;gt;\share\icons\Adwaita\&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;.\share\icons\Adwaita\&amp;lt;/code&amp;gt;:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
16x16\actions\*&lt;br /&gt;
16x16\devices\*&lt;br /&gt;
16x16\mimetypes\*&lt;br /&gt;
16x16\places\*&lt;br /&gt;
16x16\status\*&lt;br /&gt;
48x48\devices\*&lt;br /&gt;
24x24\status\image-missing.png&lt;br /&gt;
&lt;br /&gt;
icon-theme.cache&lt;br /&gt;
index.theme&lt;br /&gt;
&lt;br /&gt;
cursors\plus.cur&lt;br /&gt;
cursors\sb_h_double_arrow.cur&lt;br /&gt;
cursors\sb_left_arrow.cur&lt;br /&gt;
cursors\sb_right_arrow.cur&lt;br /&gt;
cursors\sb_v_double_arrow.cur&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following files also need to be copied:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;prefix&amp;gt;\bin\gspawn-&amp;lt;win32|win64&amp;gt;-helper.exe -&amp;gt; .&lt;br /&gt;
&amp;lt;prefix&amp;gt;\bin\gspawn-&amp;lt;win32|win64&amp;gt;-helper-console.exe -&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
&amp;lt;prefix&amp;gt;\lib\gdk-pixbuf-2.0 -&amp;gt; .\lib\gdk-pixbuf-2.0&lt;br /&gt;
&lt;br /&gt;
&amp;lt;prefix&amp;gt;\share\glib-2.0\schemas\gschemas.compiled -&amp;gt; .\share\glib-2.0\schemas&lt;br /&gt;
&amp;lt;prefix&amp;gt;\share\lensfun\version_1\* -&amp;gt; .\share\lensfun&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Creating a distributable package ==&lt;br /&gt;
&lt;br /&gt;
If you plan to distribute RawTherapee packages for the Windows platform, as a first step you need to make sure that RawTherapee will be built for the &amp;quot;generic&amp;quot; processor target. To do so, use &amp;lt;code&amp;gt;-DPROC_TARGET_NUMBER=&amp;quot;1&amp;quot;&amp;lt;/code&amp;gt; in the CMake command.&lt;br /&gt;
&lt;br /&gt;
During compilation, a script named &amp;lt;code&amp;gt;WindowsInnoSetup.iss&amp;lt;/code&amp;gt; is created in the RawTherapee installation folder. This script is used by Inno Setup [http://www.jrsoftware.org/isinfo.php], a program which is used to generate installers for Windows programs. It is advised to download the Unicode version [http://www.jrsoftware.org/download.php/is-unicode.exe] to avoid problems with some languages.&lt;br /&gt;
&lt;br /&gt;
The current &amp;lt;code&amp;gt;WindowsInnoSetup.iss&amp;lt;/code&amp;gt; script is designed for the &amp;lt;code&amp;gt;gtk2&amp;lt;/code&amp;gt; branch. If you want to create a package for a GTK3 build (&amp;lt;code&amp;gt;dev&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;releases&amp;lt;/code&amp;gt; branches) you will need to edit the script and replace the line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
Source: &amp;quot;{#MyBuildBasePath}\lib\*&amp;quot;; DestDir: &amp;quot;{app}\lib\&amp;quot;; Flags: ignoreversion recursesubdirs createallsubdirs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
Source: &amp;quot;{#MyBuildBasePath}\share\*&amp;quot;; DestDir: &amp;quot;{app}\share\&amp;quot;; Flags: ignoreversion recursesubdirs createallsubdirs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
so that icons and schemas will be copied into the package.&lt;br /&gt;
&lt;br /&gt;
To help users [[How_to_write_useful_bug_reports|write useful bug reports]], package maintainers are encouraged to produce builds which include both a &amp;quot;release&amp;quot; and a &amp;quot;debug&amp;quot; executable, and to bundle them together with the GDB debugger executable. In other words, put the &amp;lt;code&amp;gt;rawtherapee.exe&amp;lt;/code&amp;gt; (release) file together with the &amp;lt;code&amp;gt;rawtherapee-debug.exe&amp;lt;/code&amp;gt; (debug) file and the &amp;lt;code&amp;gt;gdb.exe&amp;lt;/code&amp;gt; file together into the same installer or the same archive. An alternative is to produce &amp;quot;relwithdebinfo&amp;quot; builds - these are much faster than &amp;quot;debug&amp;quot; but not as optimized as &amp;quot;release&amp;quot; builds, yet they provide just about as much useful information as &amp;quot;debug&amp;quot; builds. When making &amp;quot;relwithdebinfo&amp;quot; or &amp;quot;debug&amp;quot; builds you must provide the GDB debugger executable. Windows binaries of the debugger &amp;lt;code&amp;gt;gdb.exe&amp;lt;/code&amp;gt; can be downloaded from [http://www.equation.com/servlet/equation.cmd?fa=gdb here] in 32- and 64-bit versions.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;gdb.exe&amp;lt;/code&amp;gt; binary, available from http://www.gnu.org/software/gdb/, should be copied into the RawTherapee installation folder and, if using Inno Setup to generate the package, the &amp;lt;code&amp;gt;WindowsInnoSetup.iss&amp;lt;/code&amp;gt; script should be edited by uncommenting (removing the semicolon from the front of) the following around line 114 of the script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
;Source: &amp;quot;{#MyBuildBasePath}\gdb.exe&amp;quot;; DestDir: &amp;quot;{app}&amp;quot;; Flags: ignoreversion&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now that everything is set up, to create the package right-click on the &amp;lt;code&amp;gt;WindowsInnoSetup.iss&amp;lt;/code&amp;gt; script and choose ''Compile'' from the context menu. It will automatically generate the installer and place it in the parent folder.&lt;br /&gt;
&lt;br /&gt;
To make your new package compatible with the RawTherapee website's upload panel, create a zip archive in which you will place both the newly created installer and the corresponding ''AboutThisBuild.txt'' file which can be found at the same place. Name the resulting zip archive following this template:&lt;br /&gt;
&amp;lt;code&amp;gt;RawTherapee_&amp;lt;WinXP|WinVista&amp;gt;_&amp;lt;32|64&amp;gt;_&amp;lt;version&amp;gt;_&amp;lt;buildtype&amp;gt;.zip&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;WinXP&amp;quot; means that the build is only for Windows XP. &amp;quot;WinVista&amp;quot; means it can run on any version of Windows from Vista upwards, including 10.&lt;br /&gt;
* The &amp;quot;version&amp;quot; will either look like &amp;lt;code&amp;gt;5.2&amp;lt;/code&amp;gt; if you checkout the &amp;lt;code&amp;gt;5.2&amp;lt;/code&amp;gt; tag, or &amp;lt;code&amp;gt;5.2-dev-g1a2b3c4d&amp;lt;/code&amp;gt; if you checkout the &amp;lt;code&amp;gt;dev&amp;lt;/code&amp;gt; branch after 5.2 was tagged.&lt;br /&gt;
* If you are shipping more than one build type in an installer, include the names of all build types, e.g. &amp;lt;code&amp;gt;release_debug&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
* &amp;lt;code&amp;gt;RawTherapee_WinVista_64_5.2_release.zip&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;RawTherapee_WinVista_64_5.2_release_debug.zip&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;RawTherapee_WinVista_64_5.2-dev-g1a2b3c4d_release_debug.zip&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sguyader</name></author>
	</entry>
	<entry>
		<id>http://rawpedia.rawtherapee.com/index.php?title=Windows&amp;diff=3513</id>
		<title>Windows</title>
		<link rel="alternate" type="text/html" href="http://rawpedia.rawtherapee.com/index.php?title=Windows&amp;diff=3513"/>
		<updated>2018-01-25T12:59:20Z</updated>

		<summary type="html">&lt;p&gt;Sguyader: /* Copy RawTherapee and required DLLs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide documents how to build RawTherapee for 32-bit or 64-bit versions of Windows using the MinGW-w64 runtime. Begin by installing and updating MSYS2 using the instructions from the [https://msys2.github.io/ MSYS2 website]. Then run the following commands using either &amp;quot;''MinGW-w64 Win32 Shell''&amp;quot; if you want to build a 32-bit version, or &amp;quot;''MinGW-w64 Win64 Shell''&amp;quot; if you want to build a 64-bit version.&lt;br /&gt;
&lt;br /&gt;
RawTherapee can be built using GTK+ versions 2 or 3. To build using GTK2 use the &amp;lt;code&amp;gt;gtk2&amp;lt;/code&amp;gt; branch; to build using GTK3 use the &amp;lt;code&amp;gt;dev&amp;lt;/code&amp;gt; branch. The last version of RawTherapee to support GTK2 is 5.0-r1-gtk2 released on 2017-02-02. Use the &amp;lt;code&amp;gt;dev&amp;lt;/code&amp;gt; branch for the latest code - it requires GTK+ &amp;gt;=3.16. We recommend using GTK+ 3.22.24 or newer as this is the first version to support native windows, without which the RawTherapee window could exhibit [https://github.com/Beep6581/RawTherapee/issues/4125 strange behavior] such as maximizing under the taskbar in Windows 10.&lt;br /&gt;
&lt;br /&gt;
== Install tools and libraries ==&lt;br /&gt;
&lt;br /&gt;
First, install a few miscellaneous tools:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
$ pacman -S tar gzip nano make diffutils intltool git&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then install the necessary development tools:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
# win32&lt;br /&gt;
$ pacman -S mingw-w64-i686-gcc mingw-w64-i686-gdb mingw-w64-i686-make mingw-w64-i686-pkg-config mingw-w64-i686-cmake&lt;br /&gt;
# win64&lt;br /&gt;
$ pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-gdb mingw-w64-x86_64-make mingw-w64-x86_64-pkg-config mingw-w64-x86_64-cmake&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and the required libraries:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
# win32&lt;br /&gt;
$ pacman -S mingw-w64-i686-gtkmm mingw-w64-i686-gtkmm3 mingw-w64-i686-lcms2 mingw-w64-i686-fftw&lt;br /&gt;
# win64&lt;br /&gt;
$ pacman -S mingw-w64-x86_64-gtkmm mingw-w64-x86_64-gtkmm3 mingw-w64-x86_64-lcms2 mingw-w64-x86_64-fftw mingw-w64-x86_64-lensfun&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Download and build libiptcdata ==&lt;br /&gt;
&lt;br /&gt;
The libiptcdata library is not yet provided by MSYS2, therefore it should be downloaded and configured using:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
$ curl -LO http://downloads.sourceforge.net/project/libiptcdata/libiptcdata/1.0.4/libiptcdata-1.0.4.tar.gz&lt;br /&gt;
$ tar xzf libiptcdata-1.0.4.tar.gz&lt;br /&gt;
$ cd libiptcdata-1.0.4&lt;br /&gt;
&lt;br /&gt;
# win32&lt;br /&gt;
$ ./configure --prefix=/mingw32&lt;br /&gt;
# win64&lt;br /&gt;
$ ./configure --prefix=/mingw64&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Afterwards the &amp;lt;code&amp;gt;Makefile&amp;lt;/code&amp;gt; needs to be opened using a text editor to remove &amp;lt;code&amp;gt;iptc&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;docs&amp;lt;/code&amp;gt; from the lists named &amp;lt;code&amp;gt;SUBDIRS&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;DIST_SUBDIRS&amp;lt;/code&amp;gt;, as building or installing will fail otherwise:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
$ nano Makefile&lt;br /&gt;
&lt;br /&gt;
# Replace&lt;br /&gt;
DIST_SUBDIRS = m4 libiptcdata po iptc docs win python&lt;br /&gt;
# with&lt;br /&gt;
DIST_SUBDIRS = m4 libiptcdata po win python&lt;br /&gt;
&lt;br /&gt;
# And replace&lt;br /&gt;
SUBDIRS = m4 libiptcdata po iptc docs win $(MAYBE_PYTHONLIB)&lt;br /&gt;
# with&lt;br /&gt;
SUBDIRS = m4 libiptcdata po win $(MAYBE_PYTHONLIB)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally build and install the library:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
$ make&lt;br /&gt;
$ make install&lt;br /&gt;
$ cd&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Download and build Clearlooks ==&lt;br /&gt;
&lt;br /&gt;
If you are building RawTherapee using GTK2 then you need the Clearlooks theme engine. You do not need it if you are building using GTK3.&lt;br /&gt;
&lt;br /&gt;
Download and build it:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
$ curl -LO http://sources.archlinux.org/other/gtk-engines/gtk-engines-2.21.0.tar.gz&lt;br /&gt;
$ tar xzf gtk-engines-2.21.0.tar.gz&lt;br /&gt;
$ cd gtk-engines-2.21.0&lt;br /&gt;
&lt;br /&gt;
# win32&lt;br /&gt;
$ ./configure --prefix=/mingw32 --disable-all --enable-clearlooks&lt;br /&gt;
# win64&lt;br /&gt;
$ ./configure --prefix=/mingw64 --disable-all --enable-clearlooks&lt;br /&gt;
&lt;br /&gt;
$ make&lt;br /&gt;
$ make install&lt;br /&gt;
$ cd&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Clone and build RawTherapee ==&lt;br /&gt;
&lt;br /&gt;
Clone RawTherapee's Git repository. The build process will fail if there is a space character anywhere in your &amp;lt;code&amp;gt;build&amp;lt;/code&amp;gt; folder path. For example if your Windows username is &amp;quot;Zank Frappa&amp;quot; then your home path will be &amp;lt;code&amp;gt;C:\Users\Zank Frappa\&amp;lt;/code&amp;gt; and if you clone RawTherapee inside there then the build will fail during compilation. Simply clone to a folder where neither it nor its parent folders have a space in their name, for example &amp;lt;code&amp;gt;C:\code\repo-rt&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
$ git clone http://github.com/Beep6581/RawTherapee.git /c/code/repo-rt&lt;br /&gt;
$ cd /c/code/repo-rt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
RawTherapee can be built using GTK+ versions 2 or 3. To build using GTK2 use the &amp;lt;code&amp;gt;gtk2&amp;lt;/code&amp;gt; branch; to build using GTK3 use the &amp;lt;code&amp;gt;dev&amp;lt;/code&amp;gt; branch. The last version of RawTherapee to support GTK2 is 5.0-r1-gtk2 released on 2017-02-02. Use the &amp;lt;code&amp;gt;dev&amp;lt;/code&amp;gt; branch for the latest code - it requires GTK+ &amp;gt;=3.16. When you clone the repository you will automatically find yourself in the &amp;lt;code&amp;gt;dev&amp;lt;/code&amp;gt; branch. To switch to the &amp;lt;code&amp;gt;dev&amp;lt;/code&amp;gt; branch manually, do the following:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
$ git checkout dev&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create a separate directory for the build:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
$ mkdir build&lt;br /&gt;
$ cd build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that if you switch branches then you must delete and recreate the &amp;lt;code&amp;gt;build&amp;lt;/code&amp;gt; folder so that compilation starts from scratch in an empty folder, otherwise compilation is likely to fail. However if you are just updating without changing branches then you do not have to start with an empty build folder - you can just go into the existing one, and compilation will be faster because not everything will need to be recompiled.&lt;br /&gt;
&lt;br /&gt;
Run CMake and Make:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
$ cmake -G &amp;quot;MSYS Makefiles&amp;quot; -DLENSFUNDBDIR=share/lensfun -DCMAKE_BUILD_TYPE=&amp;quot;release&amp;quot; -DPROC_TARGET_NUMBER=&amp;quot;2&amp;quot; -DCACHE_NAME_SUFFIX=&amp;quot;5-dev&amp;quot; ..&lt;br /&gt;
$ make install&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can find an explanation of the various CMake options in the [[Linux#CMake|Linux article]], including an explanation of the various &amp;quot;BUILD_TYPE&amp;quot; options.&lt;br /&gt;
&lt;br /&gt;
If you are building for 32-bit Windows XP and are using the &amp;lt;code&amp;gt;release&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;relwithdebinfo&amp;lt;/code&amp;gt; &amp;quot;BUILD_TYPE&amp;quot;, you will need to add the &amp;lt;code&amp;gt;-mstackrealign&amp;lt;/code&amp;gt; compiler flag before the last two dots &amp;lt;code&amp;gt;..&amp;lt;/code&amp;gt; of the CMake command above:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
-DCMAKE_C_FLAGS=&amp;quot;-mstackrealign&amp;quot; -DCMAKE_CXX_FLAGS=&amp;quot;-mstackrealign&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Copy RawTherapee and required DLLs ==&lt;br /&gt;
&lt;br /&gt;
RawTherapee can now be started from the MSYS2 command line:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
# for debug builds&lt;br /&gt;
$ cd debug&lt;br /&gt;
# for release builds&lt;br /&gt;
$ cd release&lt;br /&gt;
# for relwithdebinfo builds&lt;br /&gt;
$ cd relwithdebinfo&lt;br /&gt;
$ ./rawtherapee.exe&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file manager can be used to copy the contents of &amp;lt;code&amp;gt;c:\code\repo-rt\build\&amp;lt;debug|release|relwithdebinfo&amp;gt;&amp;lt;/code&amp;gt; together with the necessary DLLs from &amp;lt;code&amp;gt;&amp;lt;MSYS2&amp;gt;\&amp;lt;mingw32|mingw64&amp;gt;\bin&amp;lt;/code&amp;gt; into a RawTherapee installation folder, where &amp;lt;code&amp;gt;&amp;lt;MSYS2&amp;gt;&amp;lt;/code&amp;gt; is the MSYS2 installation folder.&lt;br /&gt;
&lt;br /&gt;
A (possibly incomplete) list of required DLLs is:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
libatk-1.0-0.dll&lt;br /&gt;
libatkmm-1.6-1.dll&lt;br /&gt;
libbz2-1.dll&lt;br /&gt;
libcairo-2.dll&lt;br /&gt;
libcairo-gobject-2.dll&lt;br /&gt;
libcairomm-1.0-1.dll&lt;br /&gt;
libcroco-0.6-3.dll&lt;br /&gt;
libepoxy-0.dll&lt;br /&gt;
libexpat-1.dll&lt;br /&gt;
libfﬁ-6.dll&lt;br /&gt;
libfftw3f-3.dll&lt;br /&gt;
libfontconﬁg-1.dll&lt;br /&gt;
libfreetype-6.dll&lt;br /&gt;
libgcc_s_seh-1.dll&lt;br /&gt;
libgdk_pixbuf-2.0-0.dll&lt;br /&gt;
libgdk-3-0.dll&lt;br /&gt;
libgdkmm-3.0-1.dll&lt;br /&gt;
libgio-2.0-0.dll&lt;br /&gt;
libgiomm-2.4-1.dll&lt;br /&gt;
libglib-2.0-0.dll&lt;br /&gt;
libglibmm-2.4-1.dll&lt;br /&gt;
libgmodule-2.0-0.dll&lt;br /&gt;
libgobject-2.0-0.dll&lt;br /&gt;
libgomp-1.dll&lt;br /&gt;
libgraphite2.dll&lt;br /&gt;
libgtk-3-0.dll&lt;br /&gt;
libgtkmm-3.0-1.dll&lt;br /&gt;
libharfbuzz-0.dll&lt;br /&gt;
libiconv-2.dll&lt;br /&gt;
libintl-8.dll&lt;br /&gt;
libjpeg-8.dll&lt;br /&gt;
liblcms2-2.dll&lt;br /&gt;
liblensfun.dll&lt;br /&gt;
liblzma-5.dll&lt;br /&gt;
libpango-1.0-0.dll&lt;br /&gt;
libpangocairo-1.0-0.dll&lt;br /&gt;
libpangoft2-1.0-0.dll&lt;br /&gt;
libpangomm-1.4-1.dll&lt;br /&gt;
libpangowin32-1.0-0.dll&lt;br /&gt;
libpcre-1.dll&lt;br /&gt;
libpixman-1-0.dll&lt;br /&gt;
libpng16-16.dll&lt;br /&gt;
librsvg-2-2.dll&lt;br /&gt;
libsigc-2.0-0.dll&lt;br /&gt;
libstdc++-6.dll&lt;br /&gt;
libsystre-0.dll&lt;br /&gt;
libtiff-5.dll&lt;br /&gt;
libtre-5.dll&lt;br /&gt;
libwinpthread-1.dll&lt;br /&gt;
libxml2-2.dll&lt;br /&gt;
zlib1.dll&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following files also need to be copied:&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;prefix&amp;gt;\bin\gspawn-&amp;lt;win32|win64&amp;gt;-helper.exe -&amp;gt; .&lt;br /&gt;
&amp;lt;prefix&amp;gt;\bin\gspawn-&amp;lt;win32|win64&amp;gt;-helper-console.exe -&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
&amp;lt;prefix&amp;gt;\lib\gdk-pixbuf-2.0 -&amp;gt; .\lib\gdk-pixbuf-2.0&lt;br /&gt;
&lt;br /&gt;
&amp;lt;prefix&amp;gt;\share\glib-2.0\schemas\gschemas.compiled -&amp;gt; .\share\glib-2.0\schemas&lt;br /&gt;
&amp;lt;prefix&amp;gt;\share\lensfun\version_1\* -&amp;gt; .\share\lensfun&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
where &amp;lt;code&amp;gt;&amp;lt;prefix&amp;gt;&amp;lt;/code&amp;gt; is &amp;lt;code&amp;gt;&amp;lt;MSYS2&amp;gt;\&amp;lt;mingw32|mingw64&amp;gt;&amp;lt;/code&amp;gt; from above and &amp;lt;code&amp;gt;.&amp;lt;/code&amp;gt; is the installation folder.&lt;br /&gt;
&lt;br /&gt;
== Creating a distributable package ==&lt;br /&gt;
&lt;br /&gt;
If you plan to distribute RawTherapee packages for the Windows platform, as a first step you need to make sure that RawTherapee will be built for the &amp;quot;generic&amp;quot; processor target. To do so, use &amp;lt;code&amp;gt;-DPROC_TARGET_NUMBER=&amp;quot;1&amp;quot;&amp;lt;/code&amp;gt; in the CMake command.&lt;br /&gt;
&lt;br /&gt;
During compilation, a script named &amp;lt;code&amp;gt;WindowsInnoSetup.iss&amp;lt;/code&amp;gt; is created in the RawTherapee installation folder. This script is used by Inno Setup [http://www.jrsoftware.org/isinfo.php], a program which is used to generate installers for Windows programs. It is advised to download the Unicode version [http://www.jrsoftware.org/download.php/is-unicode.exe] to avoid problems with some languages.&lt;br /&gt;
&lt;br /&gt;
The current &amp;lt;code&amp;gt;WindowsInnoSetup.iss&amp;lt;/code&amp;gt; script is designed for the &amp;lt;code&amp;gt;gtk2&amp;lt;/code&amp;gt; branch. If you want to create a package for a GTK3 build (&amp;lt;code&amp;gt;dev&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;releases&amp;lt;/code&amp;gt; branches) you will need to edit the script and replace the line:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
Source: &amp;quot;{#MyBuildBasePath}\lib\*&amp;quot;; DestDir: &amp;quot;{app}\lib\&amp;quot;; Flags: ignoreversion recursesubdirs createallsubdirs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
with&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
Source: &amp;quot;{#MyBuildBasePath}\share\*&amp;quot;; DestDir: &amp;quot;{app}\share\&amp;quot;; Flags: ignoreversion recursesubdirs createallsubdirs&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
so that icons and schemas will be copied into the package.&lt;br /&gt;
&lt;br /&gt;
To help users [[How_to_write_useful_bug_reports|write useful bug reports]], package maintainers are encouraged to produce builds which include both a &amp;quot;release&amp;quot; and a &amp;quot;debug&amp;quot; executable, and to bundle them together with the GDB debugger executable. In other words, put the &amp;lt;code&amp;gt;rawtherapee.exe&amp;lt;/code&amp;gt; (release) file together with the &amp;lt;code&amp;gt;rawtherapee-debug.exe&amp;lt;/code&amp;gt; (debug) file and the &amp;lt;code&amp;gt;gdb.exe&amp;lt;/code&amp;gt; file together into the same installer or the same archive. An alternative is to produce &amp;quot;relwithdebinfo&amp;quot; builds - these are much faster than &amp;quot;debug&amp;quot; but not as optimized as &amp;quot;release&amp;quot; builds, yet they provide just about as much useful information as &amp;quot;debug&amp;quot; builds. When making &amp;quot;relwithdebinfo&amp;quot; or &amp;quot;debug&amp;quot; builds you must provide the GDB debugger executable. Windows binaries of the debugger &amp;lt;code&amp;gt;gdb.exe&amp;lt;/code&amp;gt; can be downloaded from [http://www.equation.com/servlet/equation.cmd?fa=gdb here] in 32- and 64-bit versions.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;gdb.exe&amp;lt;/code&amp;gt; binary, available from http://www.gnu.org/software/gdb/, should be copied into the RawTherapee installation folder and, if using Inno Setup to generate the package, the &amp;lt;code&amp;gt;WindowsInnoSetup.iss&amp;lt;/code&amp;gt; script should be edited by uncommenting (removing the semicolon from the front of) the following around line 114 of the script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre style=&amp;quot;white-space: pre-wrap&amp;quot;&amp;gt;&lt;br /&gt;
;Source: &amp;quot;{#MyBuildBasePath}\gdb.exe&amp;quot;; DestDir: &amp;quot;{app}&amp;quot;; Flags: ignoreversion&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now that everything is set up, to create the package right-click on the &amp;lt;code&amp;gt;WindowsInnoSetup.iss&amp;lt;/code&amp;gt; script and choose ''Compile'' from the context menu. It will automatically generate the installer and place it in the parent folder.&lt;br /&gt;
&lt;br /&gt;
To make your new package compatible with the RawTherapee website's upload panel, create a zip archive in which you will place both the newly created installer and the corresponding ''AboutThisBuild.txt'' file which can be found at the same place. Name the resulting zip archive following this template:&lt;br /&gt;
&amp;lt;code&amp;gt;RawTherapee_&amp;lt;WinXP|WinVista&amp;gt;_&amp;lt;32|64&amp;gt;_&amp;lt;version&amp;gt;_&amp;lt;buildtype&amp;gt;.zip&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;WinXP&amp;quot; means that the build is only for Windows XP. &amp;quot;WinVista&amp;quot; means it can run on any version of Windows from Vista upwards, including 10.&lt;br /&gt;
* The &amp;quot;version&amp;quot; will either look like &amp;lt;code&amp;gt;5.2&amp;lt;/code&amp;gt; if you checkout the &amp;lt;code&amp;gt;5.2&amp;lt;/code&amp;gt; tag, or &amp;lt;code&amp;gt;5.2-dev-g1a2b3c4d&amp;lt;/code&amp;gt; if you checkout the &amp;lt;code&amp;gt;dev&amp;lt;/code&amp;gt; branch after 5.2 was tagged.&lt;br /&gt;
* If you are shipping more than one build type in an installer, include the names of all build types, e.g. &amp;lt;code&amp;gt;release_debug&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
* &amp;lt;code&amp;gt;RawTherapee_WinVista_64_5.2_release.zip&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;RawTherapee_WinVista_64_5.2_release_debug.zip&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;RawTherapee_WinVista_64_5.2-dev-g1a2b3c4d_release_debug.zip&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sguyader</name></author>
	</entry>
	<entry>
		<id>http://rawpedia.rawtherapee.com/index.php?title=Local_Lab_Controls&amp;diff=3351</id>
		<title>Local Lab Controls</title>
		<link rel="alternate" type="text/html" href="http://rawpedia.rawtherapee.com/index.php?title=Local_Lab_Controls&amp;diff=3351"/>
		<updated>2017-11-20T00:11:26Z</updated>

		<summary type="html">&lt;p&gt;Sguyader: /* Processing time and memory use */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What kind of local control?==&lt;br /&gt;
&lt;br /&gt;
Several types of local control exist in mainstream applications :&lt;br /&gt;
# “lasso”, associated with layers and fusion masks (e.g. Photoshop©). This kind of control is widespread (Photoshop, Gimp, Darktable…) and users tend to favor those, at the expense of the type described in 3. below, which is less well known;&lt;br /&gt;
# dedicated tools for the removal of image defects such as “red eyes”, or “spots” associated with sensor imperfections or dirt;&lt;br /&gt;
# “U-points” controls, used until recently in Nikon Capture NX2©, or as an add-on to other software such as Nik Software©. For those (rare now) who tried such programs, there’s no way turning back to layers and fusion masks! This type of local control requires learning something different, and a cognitive “reprogramming”. In my opinion, this kind of local control is globally more efficient.&lt;br /&gt;
&lt;br /&gt;
The algorithm developed in the current version of RawTherapee is close in its principle to the U-points described above. Of course, the code used in Nik Software is not disclosed, but several years ago I was attracted by the simplicity of use and the efficiency of U-points, and I started developing a product which would use neither lassos, nor layers or fusion masks. Of course, nothing prevents us from having all 3 types of local control in the same program.&lt;br /&gt;
&lt;br /&gt;
The current version of the filter is perfectible, particularly regarding the user interface (GUI):&lt;br /&gt;
* for managing and viewing the RT-spots (control spots) on screen,&lt;br /&gt;
* for manipulating the different sliders, which would ideally be better if integrated to the actual control points, as done in Nik Software.&lt;br /&gt;
&lt;br /&gt;
However, those two aspects don’t harm everyday use, nor code portability.&lt;br /&gt;
&lt;br /&gt;
In order to improve manipulation and avoid long menus on screen, I added a GUI interface which is similar to the one used in the Wavelet tab, with “expanders”. Thus for each module (“Color and Light”, “Blur”, “Retinex”, …) you can choose to:&lt;br /&gt;
# display (or not) the full list of commands: sliders methods, curves…&lt;br /&gt;
# activate (or not) all the functions of the module.&lt;br /&gt;
&lt;br /&gt;
Warning: The second choice activates or cancels all the RT-spots. (It would be possible in theory to add this capability to every single RT-spot, but for what purpose?)&lt;br /&gt;
&lt;br /&gt;
===Lab and RGB local controls===&lt;br /&gt;
* The first algorithms are coded in L*a*b* mode with the following modules: “Color and Light”, “Blur / Add noise”, “Retinex”, “Tone mapping”, “Sharpen”, “Contrast by Detail Levels”, “Denoise”. Two additional modules have been added: “Exposure” and “Vibrance”.&lt;br /&gt;
* See below for the principles of the different algorithms, but one key point to remember for shape detection and artifact limitation, is that the Lab mode preserves the “hue” tint, which is crucial.&lt;br /&gt;
* The idea of an “RGB” module comes to one’s mind, with ''a minima'':&lt;br /&gt;
** a “White balance” module, which would allow to locally adjust the white balance, for example to warm up shadows, or to deal with mixed scene lighting such as “daylight” and “tungsten”. This module needs to be inserted just after “demosaic”.&lt;br /&gt;
&lt;br /&gt;
====Auto White balance====&lt;br /&gt;
The “White balance” module (in the “autowblocal” branch) serves two purposes:&lt;br /&gt;
* allowing a local adjustment of the white balance (of course)&lt;br /&gt;
* testing new algorithms for automatic white balance adjustment:&lt;br /&gt;
** in general use (full image), in order to achieve better results than with the current algorithm. Of course one will tell me that I should create a specific branch for “White balance”, but here I’m trying to hit two targets with one bullet.&lt;br /&gt;
&lt;br /&gt;
As a reminder, I’ve been asked in 2012 and 2013 to develop an iterative white balance “Auto Robust WB[http://ieeexplore.ieee.org/document/1649677/]”. At that time, another developer and I had spent a lot of time on this for an unsatisfactory result, so we gave up. Since then, benefiting from this experience, I resumed this work but in the reverse way! Now, if I’m correct, the algorithm works. I took advantage of this new capability (currently working on raw images only) to search in the academic literature for other auto WB algorithms. I found, and developed two new algorithms:&lt;br /&gt;
* “auto edge”[https://www.researchgate.net/publication/301419990_A_Method_to_Improve_Robustness_of_the_Gray_World_Algorithm]: the idea is to create an accentuation mask allowing to reinforce parts of the image where details are more prevalent, compared to flatter regions.&lt;br /&gt;
* “auto standard deviation”[http://www.acad.bg/rismim/itc/sub/archiv/Paper3_1_2012.pdf]: here, the image (or part of it for the local control) is divided in 12 zones, for each of which mean and standard deviation are computed, and the result assembled.&lt;br /&gt;
A third algorithm, “Color by correlation”[https://courses.cs.washington.edu/courses/cse467/08au/labs/l5/whiteBalance.pdf], looks promising but I’m facing several difficulties. After many trials of many types, the results are just too erratic…&lt;br /&gt;
&lt;br /&gt;
I also added the notion of gamma:&lt;br /&gt;
* the same principles which deal with luminance distribution – gamma sRGB – used in the main RawTherapee code.&lt;br /&gt;
&lt;br /&gt;
Bear in mind that the automatic white balancing is a totally non deterministic mathematical problem. The algorithms may perform more or less well (and faster or slower), but a perfect result can’t exist! Why is it so? If one is referring to the principles of color management ([http://rawpedia.rawtherapee.com/Color_Management_addon/fr#Balance_des_blancs]), it is necessary to have knowledge of the three of: the coloured object, the illuminant and the observer. At least two of those are unknown in practice. In addition, the environment in which an image is shot is not known while it has an effect on the perception (CIECAM), and the same is true during both image editing and viewing. The mission is thus almost impossible!&lt;br /&gt;
&lt;br /&gt;
The aim of the “White balance” module is '''for testing the algorithms''', there are 7 of them at least, and twice that number if “gamma sRGB” is considered. Indeed, in order to circumvent the obstacles encountered five years ago, instead of the using the image before demosaicing, I used the image just after demosaicing, allowing to apply (or not) “gamma sRGB”, ending in the same conditions as in normal use (but without normal “White balance” and “ICC or DCP” profile).&lt;br /&gt;
&lt;br /&gt;
Ideally, we should test the algorithms on many images, as well: which algorithm(s) to keep and implement in normal – global RGB – mode (maybe one or two, in addition to the current algorithm which we should keep for compatibility).&lt;br /&gt;
&lt;br /&gt;
====Local control of White balance====&lt;br /&gt;
The local control is currently limited to 1 spot only, but there’s no difficulty to increase this if users want so… while waiting for the evolution of “locallab”.&lt;br /&gt;
&lt;br /&gt;
Of course, I hear voices say “it doesn’t work”, or “the output doesn’t match with the preview”. But it does work! And it is more than evident that matching exactly the preview is by definition almost impossible… (differences between shadows, sun light, different illuminants, etc…) whatever the relevance of the algorithm.&lt;br /&gt;
&lt;br /&gt;
==What are the challenges we need to solve?==&lt;br /&gt;
Several general issues need to be solved so as to achieve smoothness in use:&lt;br /&gt;
* allow an (almost) unlimited number of RT-spots (the name we chose for the control spots in RawTherapee);&lt;br /&gt;
* adapt the local algorithms to be aware of scale, because many of them take the image size – the treated area – into account. This aspect is fundamental, particularly with curves which act on the whole image;&lt;br /&gt;
* minimise memory use and computation time for JPG and TIFF output;&lt;br /&gt;
* allow easy updates in case of evolution of either the algorithms or the number of methods/modules;&lt;br /&gt;
* optimise (minimise) the differences between the preview and the output.&lt;br /&gt;
* etc…&lt;br /&gt;
&lt;br /&gt;
For each RT-spot:&lt;br /&gt;
* allow for the action to occur, on user choice, either inside or outside (“Inverse” mode) of the selection area;&lt;br /&gt;
* allow shape detection, on user choice, in order to limit the action based on features/shapes;&lt;br /&gt;
* take care of the transition between the center of the treated area and the other parts of the image;&lt;br /&gt;
* etc…&lt;br /&gt;
&lt;br /&gt;
Currently, RT-spots are operational in Lab mode with the following modules and methods:&lt;br /&gt;
# “Colour and Light”: “Lightness”, “Chrominance”, “Contrast” in normal mode with 4 curves L=f(L), L=f(H), C=f(C), H=f(H), and in “inverse” mode;&lt;br /&gt;
# “Exposure”: normal mode only;&lt;br /&gt;
# “Vibrance:” normal mode only;&lt;br /&gt;
# “Blur &amp;amp; noise”: normal and “inverse” modes;&lt;br /&gt;
# “Retinex”: normal and “inverse” modes, now also with “transmission gain” curve;&lt;br /&gt;
# “Sharpening”: normal and “inverse” modes;&lt;br /&gt;
# “Contrast by detail levels” (CBDL): normal mode only;&lt;br /&gt;
# “Denoise”: normal mode only.&lt;br /&gt;
&lt;br /&gt;
==General principles==&lt;br /&gt;
===The RT-spot object===&lt;br /&gt;
As I mentioned earlier, the system used in RT is similar to the one developed in Nik Software, but with some significant differences:&lt;br /&gt;
* each RT-spot can be viewed as an object with a number of fields (about 70 as of today), made of sliders, curves, control points, etc…;&lt;br /&gt;
* each field, grouped in modules, can be activated or not, and have different parameter values according to their nature;&lt;br /&gt;
* the modules are made to be coherent for the user: “Color and Light”, “Exposure”, “Contrast”, “Vibrance”, “Blur”, “Retinex”, “Sharpening”, “Tone Mapping”, “Contrast by detail levels”, “Denoise”;&lt;br /&gt;
* the number of RT-spot objects can vary from 2 up to 500;&lt;br /&gt;
* data describing the RT-spot objects are stored in text files with .mip extension;&lt;br /&gt;
* creating, modifying and tracking of the RT-spot objects are done in a “for” loop;&lt;br /&gt;
* there’s no code duplication.&lt;br /&gt;
&lt;br /&gt;
===Partitioning into 4 zones – previewing the RT-spot area===&lt;br /&gt;
When the user selects an RT-spot, the screen preview shows:&lt;br /&gt;
* a centre, made of a circle whose diameter and position can be adjusted directly using the mouse or the sliders;&lt;br /&gt;
* two horizontal and two vertical handles, whose position can be modified directly using the mouse or the provided sliders, controlling the extent of the area affected by the RT-spot;&lt;br /&gt;
* if &amp;quot;Show spot delimiters&amp;quot; is checked in &amp;quot;Preferences&amp;quot; &amp;gt; &amp;quot;General&amp;quot; tab &amp;gt; &amp;quot;Local adjustments&amp;quot;, one can visualise approximately the area affected by the spot. Because I couldn’t work cleanly with the « arc/ellipse/scale » function in the Cairo graphics library, I made each quadrant defined by a pseudo-ellipse made of 3 Bézier curves joining each other. In most cases the approximation is satisfying… To help grabbing the 4 handles, I made them longer (the Bézier curves are inactive!).&lt;br /&gt;
&lt;br /&gt;
We obtain 4 zones, whose orientation cannot be modified (the default rotation angle is set to zero). Those 4 zones have each of their vertices connected by imaginary ellipses.&lt;br /&gt;
&lt;br /&gt;
It is possible to drag the handles outside the image preview area.&lt;br /&gt;
&lt;br /&gt;
It should be possible to replace the ellipse with a hand drawn curve (even if I think its usefulness is debatable because of the existence of the shape detection algorithm), as long as the homothetic transform of the curve doesn’t intersect with the original curve. Although the benefits from this intellectually satisfying “improvement” should negligible in the case of the RT-spots, it will be possible to make the current RT-spots and lasso type of controls coexist eventually.&lt;br /&gt;
&lt;br /&gt;
===The &amp;quot;normal&amp;quot; and &amp;quot;excluding&amp;quot; types of RT-spots===&lt;br /&gt;
Two types of RT-spots are available:&lt;br /&gt;
* &amp;quot;Normal&amp;quot;: these are the spots which do the local retouching. Each new RT-spot takes into account the effect of existing spots when their zone of influence overlap (a sort of recursive action).&lt;br /&gt;
* &amp;quot;Excluding&amp;quot;: adding a new &amp;quot;excluding&amp;quot; RT-spot allows to revert the effect created by a &amp;quot;normal&amp;quot; RT-spot in their overlapping zone of influence , from the original image data (but doing its calculations from the reference values of the area affected by the &amp;quot;normal&amp;quot; RT-spot).&lt;br /&gt;
&lt;br /&gt;
For both types, the user has access to most of the modules (&amp;quot;Color and Light&amp;quot;, &amp;quot;Contrast by detail levels&amp;quot;, &amp;quot;Blur&amp;quot;, ...)&lt;br /&gt;
&lt;br /&gt;
====Comments about the &amp;quot;excluding&amp;quot; RT-spot====&lt;br /&gt;
* The principle of the &amp;quot;excluding&amp;quot; spot is similar to the &amp;quot;counterpoint&amp;quot; in Capture NX2, and is useful when for example, the effect of a &amp;quot;normal&amp;quot; RT-spot bleeds into an area which the user wants to be unaffected. This unwanted effect happens when when the tints of the two areas (the area the user wants to be affected, and the area one wants to remain unaffected) are to close.&lt;br /&gt;
* The underlying algorithm is similar to the main algorithms used elsewhere in &amp;quot;locallab&amp;quot;, and is based on tint differences. While it's not perfect it should give satisfaction 70% of the time.&lt;br /&gt;
* I implemented an additional algorithm (with no guarantee that it will actually work one day) to help discriminate the areas, based on a Sobel-Canny transform. The transform is coded but is not yet accessible to the user, as I'm still working to make it more efficient.&lt;br /&gt;
&lt;br /&gt;
====How to use the &amp;quot;excluding&amp;quot; RT-spot, and its limitations====&lt;br /&gt;
# Create a new RT-spot over the area you want to restore.&lt;br /&gt;
# In the &amp;quot;Settings&amp;quot; panel, from the &amp;quot;Spot method&amp;quot; combobox choose &amp;quot;Excluding spot&amp;quot;.&lt;br /&gt;
# Adjust &amp;quot;Scope&amp;quot;, &amp;quot;Transition&amp;quot; and &amp;quot;Spot size&amp;quot; as well as the shape of the zone of influence using the 4 handles, until you get the desired reversion of the effect. You can use complimentary adjustments such as &amp;quot;Color and light&amp;quot;, etc.&lt;br /&gt;
The algorithm computes the reference values (tint, chroma, luma) from the the current image (see below). As a consequence, the &amp;quot;excluding&amp;quot; effect won't work if the image area is black (for example when the user uses a normal RT-spot using &amp;quot;Color and light&amp;quot; in inverse mode to create a black frame).&lt;br /&gt;
Sometimes, when the &amp;quot;inverse&amp;quot; mode is selected, the &amp;quot;excluding&amp;quot; spot algorithm may not work as expected and lead to a difference between the preview and the output (JPG, TIFF) image. Increasing the value of &amp;quot;Scope&amp;quot; of the &amp;quot;excluding&amp;quot; RT-spot should help in this situation.&lt;br /&gt;
&lt;br /&gt;
===Tint, chroma, luminance references and the algorithm principle in “normal” mode===&lt;br /&gt;
In order to develop an efficient shape detection algorithm:&lt;br /&gt;
* The central circle zone is used as the reference. Based on the diameter value chosen by the user, the algorithm computes the tint (hue), chroma and luminance averages.&lt;br /&gt;
* The choice of the central zone diameter depends on the use intent. For example, if working on a foliage area the user would benefit from choosing a smaller diameter value in order to select only the foliage green; in contrast, for skin tones the user should increase the diameter to avoid the detection of parasites (noise, eye lashes…).&lt;br /&gt;
* For each quadrant, depending on the the value of the “Scope” slider, the algorithm does:&lt;br /&gt;
# take into account the tint difference between the zone centre and the affected pixel;&lt;br /&gt;
# through a complex algorithm based on the deltaE notion (perceived difference between two colours, taking tint, chroma and luminance into account), decrease the amount of applied effect as a function of the difference between the central zone and the affected pixel;&lt;br /&gt;
# follow either a linear or a parabolic law to adjust the amount of applied effect, based on the specific the case.&lt;br /&gt;
&lt;br /&gt;
This allows adapting the amount of effect according to the above-mentioned criteria. For example, if the central circle is located on foliage, the action will be limited to the leaves, without touching the background (which would be impossible to obtain with the lasso type of controls). Additionally, if some other foliage resides within the area covered by the RT-spot, it will also be affected.&lt;br /&gt;
* Adjusting the value of the “Transition” slider modifies the transition of the effect (from the centre to the edge): on 50, the inner (linear) half will get the full 100% action/effect, while the effect in the outer half will gradually transition from 100% to 0% towards the edge;&lt;br /&gt;
* By increasing the value of “Scope”, progressively more of the selected area is taken into account, whatever the tint, chroma and luminance;&lt;br /&gt;
* Conversely, by decreasing the “Scope” value the effect will get limited to the pixels which are more similar (in terms of deltaE) to the reference zone.&lt;br /&gt;
&lt;br /&gt;
The shape detection algorithm works in “Normal” mode except for some modules (“Denoise”). It’s not implemented in “Inverse” mode, doing so would not make sense.&lt;br /&gt;
&lt;br /&gt;
The algorithm will see its performance increase when the user chooses “Enhanced” or “Enhanced + chroma denoise” in the “Global quality:” combobox. The second choice additionally applies a low amount of chroma noise reduction in order to get rid of artefacts which could be brought up by the “Enhanced” algorithm (note that the chroma denoise step increases memory use and computing time).&lt;br /&gt;
&lt;br /&gt;
The algorithm is used in full capacity for “scope” &amp;lt; 20.&lt;br /&gt;
&lt;br /&gt;
===Why no alternative algorithms?===&lt;br /&gt;
It should be possible to implement other shape detection algorithms than the deltaE-based one used currently, for example:&lt;br /&gt;
* edge detection algorithms such as “Canny” or “Sobel”;&lt;br /&gt;
* wavelet decomposition.&lt;br /&gt;
&lt;br /&gt;
But in both cases, everything would have to be done!&lt;br /&gt;
&lt;br /&gt;
===Functioning in “inverse” mode===&lt;br /&gt;
When it is available, the “Inverse” mode is extremely simplified: only the “Transition” slider can be used to apply the effect.&lt;br /&gt;
As of late October 2017, I devised a new method for “Inverse” mode. It is limited to the “Blur &amp;amp; Noise” module (see the corresponding section below).&lt;br /&gt;
&lt;br /&gt;
===Maximum number of RT-spots===&lt;br /&gt;
By default the number of available RT-spots is 8. You can choose any number between 2 and 499. For this you only need to change the parameter “Nspot” in the “options” file (for example: Nspot=12). Restart RawTherapee for the modification to be taken into account.&lt;br /&gt;
&lt;br /&gt;
===The “super” algorithm===&lt;br /&gt;
The key to “success” was the algorithm implemented in late January 2017, which works this way:&lt;br /&gt;
# on the pixel data which are within the area covered by the RT-spot, the algorithm applies either a “traditional” curve, a slider, or a normal transfer function (“Retinex”, “Tone Mapping”, “Contrast by detail levels”, “Vibrance”, …);&lt;br /&gt;
# the LUT or the transfer function is converted into an equivalent of a slider, separating negative and positive values so that the function can be viewed as multiple sliders (as many sliders as there are pixels) in the -100, 0, +100 interval;&lt;br /&gt;
# the data are passed to the shape detection function – the 4 quadrants. For every pixel, the difference in terms of tint, chroma and luma is computed with regards to the central reference. The linear variation equations are estimated for luminance (L=f(L)), chroma (C=f(C)) or transfer functions;&lt;br /&gt;
# different corrections are applied to account for the environment (sky, skin tones…)&lt;br /&gt;
# a correction is made (with threshold and iterations) in order to avoid correcting (or only slightly, based on the user’s choice) the grey or neutral tones which are in the same tint as the reference (but with a low chroma value);&lt;br /&gt;
# the parameters are weighted based on the shape of the RT-spot (ellipses) and the transition zone;&lt;br /&gt;
# the values of the “Global quality:” parameters are important, particularly so for images with a low amount of noise – chroma noise is interpreted by the algorithm being of the same colour as the spot. It is thus necessary to suppress this noise, that is the purpose of “Enhanced + chroma denoise” (this algorithm may not be sufficient, though – in this case using the local “Denoise” module may be useful).&lt;br /&gt;
&lt;br /&gt;
This new (“super”) algorithm seems to perform generally well, but in the event when the RT-spot is located in a grey/neutral or flat area, the algorithm may fail. In such cases, using the old algorithm is recommended (except for “Retinex”, “Tone Mapping” and “Contrast by detail levels” for which it is made unavailable for the sake of code simplicity).&lt;br /&gt;
&lt;br /&gt;
===Artefact reduction and the “Global quality” algorithms===&lt;br /&gt;
By default, “Global quality:” is set to “Enhanced + chroma denoise”. Whereas it increases computation time, it is still generally preferable. In case one wants a more responsive preview, “Enhance” or “Standard” can be chosen (good for exploring the image).&lt;br /&gt;
* two sliders allow reducing artefacts and improving the algorithm’s rendering. They work based on chroma, in neutral/gray tones. To completely remove its effect, one can simply set “iterations=0”. These sliders may be used for &amp;quot;Color light&amp;quot;, &amp;quot;Exposure&amp;quot;, &amp;quot;Retinex&amp;quot;, &amp;quot;Vibrance&amp;quot;, &amp;quot;Tone mapping&amp;quot; and &amp;quot;Contrast by detail levels&amp;quot;;&lt;br /&gt;
* for (even slightly) noisy images, the algorithms may be misled. In this case it is recommended to keep &amp;quot;Global quality:”  set to “Enhanced + chroma denoise&amp;quot;, and (sometimes) activate the local “Denoise” module and adjust the sliders very gently (including “Luminance”);&lt;br /&gt;
* under some circumstances, with “Tone Mapping” for example, the artefact reduction algorithm may actually generate more artefacts. When it happens, set “iterations=0”.&lt;br /&gt;
&lt;br /&gt;
If your images are generally clean (no or very low noise), you can choose to have “Standard” as the default for “Global quality:” – this will speed up the image processing. To do so, go to “Preferences” &amp;gt; “Performance and quality” tab &amp;gt; “Local adjustments” and choose the “Standard” algorithm among the 3 options. This will become the new default  when new RT-spots are created, but of course the algorithm can still be changed on the fly by choosing from the “Global quality” combo box.&lt;br /&gt;
&lt;br /&gt;
===Avoid color shift===&lt;br /&gt;
The “Avoid color shift” checkbox serves two purposes:&lt;br /&gt;
* put the colours within the current working profile gamut, using a relative colorimetry;&lt;br /&gt;
* adjust colours using a “Munsell” correction – particularly for red-orange and blue-purple colours, when saturation in the L*a*b* space has changed significantly.&lt;br /&gt;
&lt;br /&gt;
===“mip” files – Principles of the multi-point algorithm===&lt;br /&gt;
For the local control system to work and keep track of RT-spot objects, a text file – similar to a pp3 – is written in 2 possible places:&lt;br /&gt;
* next to the edited image file. If, for example, you edit an image named ASC4509.NEF, a new file named ASC4509.NEF.mip will be generated in the same folder. In this case, several sessions can be open for the same image, as long as copies of the image are stored in different folders. However, the folder names in the path have to contain ASCII characters only, otherwise it will make the program crash;&lt;br /&gt;
* in the dedicated “mip” folder, within the “cache” directory (through an MD5 hash number which identifies the file). This is the default. If chosen, when multiple copies of the same file exist in distinct folders, editing them creates as many “mip” files. This option allows the use of non ASCII characters in the folder names and path.&lt;br /&gt;
&lt;br /&gt;
The choice between these two behaviours is made in “Preferences” &amp;gt; “Image processing” tab &amp;gt; “Mip profiles”.&lt;br /&gt;
&lt;br /&gt;
The “mip” files contain the data which are passed to RawTherapee through processes of the “procparams” type, and LUTs which allow editing in zoom mode. When updating RawTherapee to a new version, it may be required to delete the “mip” files (or the whole cache) to avoid a potential crash of the application. This can be achieved by going to “Preferences” &amp;gt; “File browser” tab, then choosing “Clear mip” and/or “Clear pp3” – all this is valid only if “mip” and “pp3” files have been set to be saved to the cache folder, otherwise they will have to be manually deleted from the working folder. Keeping older “mip” and “pp3” files may lead to instability or crashes of the application.&lt;br /&gt;
&lt;br /&gt;
====Architecture of the filter====&lt;br /&gt;
When I “ventured” into a multi-point, no-layer and no-mask system, code duplication had to be avoided. Indeed, it is unthinkable to consider, for 10 RT-spots, generating 10 GUI code blocks, and just as many code blocks in “rtengine”. After careful consideration, the idea was to have a file updating and tracking in real time – i.e. a file which would follow each modification made by the user – the actions/modifications history.&lt;br /&gt;
&lt;br /&gt;
Of course, the parameters used by RawTherapee for the GUI and for the main code through “params” are of different types:&lt;br /&gt;
* numeric: integer, float, double,…&lt;br /&gt;
* Boolean&lt;br /&gt;
* string (in choice menus for the different modules)&lt;br /&gt;
* curves, through “vectors” of type double with dynamic dimension&lt;br /&gt;
* …&lt;br /&gt;
&lt;br /&gt;
====Data conversion====&lt;br /&gt;
In order to simplify data management, the first step is to convert all data to integers. Sometimes this can lead to a slight precision loss, which I think is negligible.&lt;br /&gt;
* This operation is very simple for numeric values, even though in some cases (such as hue, which is expressed in radian in the interval [-Pi, +Pi]) it needs a double “float*100 and /100 conversion to keep precision.&lt;br /&gt;
* It is logical for Boolean operations and methods.&lt;br /&gt;
* However, it is a complex matter regarding curves. The values to be recorded in the “mip” file are of type vector&amp;lt;double&amp;gt;, in a dynamic table of numeric values. There may be a simpler way, by using existing functions from “procparams”, but I didn’t succeed. &lt;br /&gt;
Nevertheless, I could get around this by:&lt;br /&gt;
# converting doubles to integers with 3 significant figures – which is largely enough,&lt;br /&gt;
# then converting the “vector” to a variable length character string,&lt;br /&gt;
# the writing and reading of this character string and converting to a vector dynamically using an appropriate function (”strcurv_data”). Note that this function allows adjusting the curves within the limit of 16 inflection points (Bézier curve) for the flat curve, and 32 points for the diagonal, which should be enough. Whether this would not be enough, it should be possible to increase that number, though compatibility would be compromised.&lt;br /&gt;
&lt;br /&gt;
====Some elements about curves====&lt;br /&gt;
The implementation of curves has been a complex task, particularly since:&lt;br /&gt;
# each curve needs its own reset function – resize() at each iteration,&lt;br /&gt;
# which implies oddities regarding their description, for example the diagonal curve gets initialised with several points, despite it looks being “empty”. This is mandatory for correct functioning, but this means that the curve is always open/active. Consequently, to avoid some unwanted loss of computation time in “preview” mode, the user has to activate the curve by clicking on the “curves” combobox. The same activation is necessary for L=f(H) and C=f(C) curves. While clicking enabling the “curves” (linear) would seem to be a better solution, it didn’t work despite many trials.&lt;br /&gt;
# during all the procedure, we need to set each &amp;quot;params&amp;quot; value to &amp;quot;clear&amp;quot; for curves, for each LUT, at each iteration and then through a &amp;quot;vector&amp;quot; to reassign the good, updated values to &amp;quot;curve params&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
====Data storing and dynamic use====&lt;br /&gt;
Once data have been converted:&lt;br /&gt;
* they are stored in a text (mip) file,&lt;br /&gt;
* each one is referenced inside a 2-dimension dynamical table:&lt;br /&gt;
# dataspot[x][y] for numeric and boolean values and methods, where “x” is the representative index of the parameter (e.g. “9” is for “lightness”) and “y” represents the current RT-spot (control spot). Value “0” represents the current in-use value (the one stores in “params”).&lt;br /&gt;
# retistr[y], llstr[y], lhstr[y], ccstr[y], hhstr[y], skinstr[y], pthstr[y], exstr[y] for parameters of type “curve”. Currently there are only 8 parameters, used for local “Retinex”, “Color and light” (L=f(L), C=f(C), L=f(H), H=F(H)), “Vibrance” and “Exposure”, but it is easy to add more. “y” is used as above in 1.&lt;br /&gt;
&lt;br /&gt;
The way data are stored and used fits well with improccoordinator.cc (current management / preview) and simpleprocess.cc (TIFF / JPG  output) files, but not so with dcrop.cc and the partial display of the image (RawTherapee’s pipeline).&lt;br /&gt;
&lt;br /&gt;
In this case (zoom / preview) another solution had to be found in order to synchronise the modifications in real time. I made use of LUTs, so that to each entry referenced in the table described above a LUTi(z) is associated, with z=500 possible entries (500 corresponds to the current maximum number of RT-spots, but this limit can be decreased or increased). The LUTi “z” corresponds to the dataspot “y”. A 25,000 entries LUTi (arbitrary number) is used for “retistr”, “llstr”, “lhstr”, “ccstr”, “hhstr”, “skinstr”, “pthstr”, “exstr” for storing each “vector” curve value in memory (up to 69 values stored as integers).&lt;br /&gt;
&lt;br /&gt;
During data processing, exchanges occur between: params, dynamic tables and LUTi. The values used by dcrop.cc are dynamically linked to dynamical tables by parent→.&lt;br /&gt;
&lt;br /&gt;
====Exchange processes and dynamic data storing====&lt;br /&gt;
# reading of the “mip” file to check the version number and guide the updates&lt;br /&gt;
# creating the “mip” file if it doesn’t exist&lt;br /&gt;
# storing the data in LUTi and dynamic tables from the values stored in “params” (index 0 values)&lt;br /&gt;
# first interactive update with the GUI through a transfer function between “rtengine” and locallab.cc (aloListener → localretChanged). This is one of the 3 functions required for the process to work correctly&lt;br /&gt;
# reading of the “mip” file and data storing in dynamic tables (index values ==&amp;gt; y) according to the number of RT-spots&lt;br /&gt;
# creating a loop – according to the number of RT-spots – which updates LUTi (required by “dcrop”) and “params” values from values stored in the dynamic tables&lt;br /&gt;
# call to the “Lab_local” function which contains the algorithms controlling each RT-spot (luminance, sharpness, retinex, denoise, …)&lt;br /&gt;
# second interactive update with the GUI through another transfer function between “rtengine” and “locallab.cc”&lt;br /&gt;
# treatment of the current RT-spot by using the index (0) values from the dynamic tables. These values are attributed to 1) “params”, 2) LUTi and 3) current index values&lt;br /&gt;
# call to the “Lab_local” function for the current RT-spots&lt;br /&gt;
# saving to the “mip” file.&lt;br /&gt;
&lt;br /&gt;
Note that if the user modifies the curve (amplitude, number of inflection points) a third interactive update is made in order to conform all of the data according to events.&lt;br /&gt;
&lt;br /&gt;
====A few unavoidable “fantasies”====&lt;br /&gt;
Of course everything looks simple, the process works if, and only if, all the data are dynamically updated. I’ve tried a lot, went groping, and finally found a working solution… but an uncanny one. There’s probably a more “informatically” correct way to do it, but at this point I’ve done as explained above and hereafter.&lt;br /&gt;
&lt;br /&gt;
The 3 exchanges between “rtengine” and the GUI occur with 3 parameters which actually do nothing in the program except doing the update process:&lt;br /&gt;
# “anbspot” which takes values of 0 or 1&lt;br /&gt;
# “cTgainshaperab” (curve) which takes any value bewteen 0.70 and 0.90&lt;br /&gt;
# “retrab” which varies around 500.&lt;br /&gt;
I have added 3 more parameters (in the form of sliders) – hueref, chromaref and lumaref – hidden from the user but which are used to update the system in real time, to correctly take into account the reference “spot” values. Allowing those 3 parameters to vary brings stability and allows real time updates. Increasing the number of those “fantasy” parameters should not be necessary. These extra parameters are hidden to the user, and are only visible in the history.&lt;br /&gt;
&lt;br /&gt;
In addition, I had to add some empirical time delays, giving time to time… Time delay is used for example when the user modifies the curve (amplitude, number of inflection points).&lt;br /&gt;
&lt;br /&gt;
==Specificity of the local mode (as compared to “Lab adjustments”)==&lt;br /&gt;
Hereafter is some useful information for the user, often specific to the local mode.&lt;br /&gt;
&lt;br /&gt;
===Color and Light===&lt;br /&gt;
* The algorithms used for luminance and contrast in local mode differ from the ones used in “Lab adjustments”, which may lead to differences in rendering.&lt;br /&gt;
* The luminance algorithm is made such that below -90 and down to -100 for “Lightness”, it is possible to increase the image's “darkness”, almost to the point of getting a luminance value close to 0. To accentuate this effect, “Chrominance” can be decreased and “Scope” increased.&lt;br /&gt;
* The inverse mode can be used for creating graduated frames. If “Ligthness” is set to -100 and &amp;quot;Chrominance&amp;quot; is reduced, the “frame border” will be black.&lt;br /&gt;
* For the “Lightness” and “Contrast” sliders, the user can choose among 2 algorithms: the first one (default) is close to that in “Lab adjustments” while the second one, activated through “Lightness - Contrast ‘Super’” is close to the algorithm used for the L=f(L) “Super” curve.&lt;br /&gt;
* Do not hesitate, when needed, to activate “Enhanced” or “Enhanced + chroma denoise” in the “Global Quality:” combobox.&lt;br /&gt;
&lt;br /&gt;
====Curves====&lt;br /&gt;
* An L=f(L) or C=f(C) curves allow controlling the luminance and chrominance for each RT-spot as a function of luminance or chrominance.&lt;br /&gt;
* An L=f(H) curve allows controlling the luminance for each RT-spot as a function of tint.&lt;br /&gt;
* An H=f(H) curve allows controlling the tint for each RT-spot as a function of tint.&lt;br /&gt;
The curves are activated by selecting one of the two algorithms from the “Curves types” combobox:&lt;br /&gt;
* “Normal”: the curves – particularly the one that is the most difficult to manage, L=f(L) – use an algorithm close to the one used with the sliders (Normal mode),&lt;br /&gt;
* “Super”: using a new algorithm, which I think performs very well (it even surprised me the first time I used it).&lt;br /&gt;
&lt;br /&gt;
Caution: when the RT-spot resides in an area which is neutral, grey or very uniform, the artefacts introduced by the new algorithm (“Super” algorithm for the curve or the slider) may be impossible to get rid of. Use one of the 2 older algorithms to avoid that.&lt;br /&gt;
&lt;br /&gt;
===Exposure===&lt;br /&gt;
The “Exposure” module may look like the the one in global RGB mode, but:&lt;br /&gt;
* it works entirely in L*a*b* mode, hence the differences in rendering;&lt;br /&gt;
* there’s no “Lightness”, “Chroma” or “Contrast” slider, whose functions are already fulfilled in the “Color and Light” module;&lt;br /&gt;
* there’s only one “Contrast” curve, similar to the L=f(L) firm “Color and Light”. Of course its effect is different from “Tone curve” which works in RGB mode. If needed, two L=f(L) curves can be activated, one under “Color and Light” and the other under “Exposure”.&lt;br /&gt;
&lt;br /&gt;
===Vibrance===&lt;br /&gt;
This module is similar to the main one (from RawTherapee's &amp;quot;Exposure&amp;quot; tab).&lt;br /&gt;
&lt;br /&gt;
===Blur &amp;amp; Noise===&lt;br /&gt;
“Blur” is activated only when “Radius” =&amp;lt; 2.&lt;br /&gt;
By significantly lowering the default value of “Scope” and possibly checking “Blur luminance only”, it is possible to get a different amount of blur for the different tints.&lt;br /&gt;
Since October 2017, 3 methods are proposed:&lt;br /&gt;
* “Normal”: the shape detection algorithm has been improved, it is now closer to shape detection algorithm proposed in the other modules;&lt;br /&gt;
* “Inverse”: a simplified algorithm, which doesn’t make use of “Scope”. The inversion is coarse and doesn’t allow a fine separation between the affected and unaffected areas;&lt;br /&gt;
* “Symmetric”: this new algorithm uses the same processes as “Normal”, and adjusting “Scope” the user can target the process with more precision.&lt;br /&gt;
Caution: &lt;br /&gt;
* Using the “Inverse” mode will blur large portions of the image, which can not be corrected later on.&lt;br /&gt;
* The action of “Scope” may sometimes appear puzzling: for instance, in a portrait, the eyes (which of course differ from the skin) may be blurred if the value of “Scope” is too low.&lt;br /&gt;
&lt;br /&gt;
===Tone Mapping===&lt;br /&gt;
Caution when uniformly coloured areas (sky, grey/neutral zones) have a similar tint to the area on which the RT-spot is placed. In cases where this leads to artefacts, set the “Iterations” slider to 0 in “Settings” &amp;gt; “Reduce artefacts – Improve algorithm”.&lt;br /&gt;
&lt;br /&gt;
===Retinex===&lt;br /&gt;
Compared to the standard “Retinex” module, the local “Retinex module has simplified controls, and is applied at the end of the pipeline instead of the beginning. Since “mip” version 10002, the “Transmission gain” is specific to each RT-spot.&lt;br /&gt;
&lt;br /&gt;
===Sharpening===&lt;br /&gt;
Only the “RL Deconvolution” algorithm is provided here.&lt;br /&gt;
&lt;br /&gt;
===Contrast by detail levels===&lt;br /&gt;
Compared to the main RGB mode module, this one has:&lt;br /&gt;
* 5 levels instead of 6,&lt;br /&gt;
* no slider for “skin tone” protection (not needed since the algorithm works locally on the RT-spot area),&lt;br /&gt;
* an additional “Chroma” slider.&lt;br /&gt;
&lt;br /&gt;
Caution when uniformly coloured areas (sky, grey/neutral zones) have a similar tint to the area on which the RT-spot is placed. In cases where this leads to artefacts, set the “Iterations” slider to 0 in “Settings” &amp;gt; “Reduce artefacts – Improve algorithm”.&lt;br /&gt;
&lt;br /&gt;
===Denoise===&lt;br /&gt;
Compared to the main RGB mode module, this one has:&lt;br /&gt;
* only the wavelet tool working (no Fourier function, nor medians),&lt;br /&gt;
* less sliders and curves,&lt;br /&gt;
* the possibility to work differentially on fine or coarse noise for both luminance and chrominance noise.&lt;br /&gt;
&lt;br /&gt;
==A specific use case : reduction of image defects (dirty sensor, red eyes, …)==&lt;br /&gt;
“Locallab” had not been thought with the idea of correcting small image defects. However, some visible, “photographically disturbing” defects may actually be tamed or even removed. Of course, this is not incompatible with other more specialised modules which could be introduced (or not) into “Locallab”… At least 3 existing modules can serve this purpose, alone or in combination, by adapting their use:&lt;br /&gt;
* “Color and Light” for spot-like defects;&lt;br /&gt;
* “Contrast by detail levels” for spread out defects;&lt;br /&gt;
* “Blur and Noise” as an optional complement (caution, this is a destructive action, use moderately).&lt;br /&gt;
&lt;br /&gt;
These modules can be used either on the main image (raw, TIFF,  …) or on a flat-field image.&lt;br /&gt;
&lt;br /&gt;
===Using the “Color and Light” module===&lt;br /&gt;
* Activate “Color and Light”&lt;br /&gt;
* A red eye removal tool equivalent can be obtained by framing closely around the eye – central circle zone centered on the eye’s red, spot handles close to the eye – low “Scope” value, then lowering “Lightness” and “Chrominance” to -100.&lt;br /&gt;
* The same idea allows reducing the “IR spot” kind of defect by framing closely around the defect – central circle zone centred on the defect, spot handles close to the defect area – then lowering “Chrominance” to taste, and if needed lowering the “scope” value.&lt;br /&gt;
* In some (simple) situations, a “dirty sensor” defect can be reduced, in particular in the case of “sensor grease”. It can be seen as stains or spots on a uniform background. To attenuate this, choose a tight framing of around the defect – central circle on the centre of the defect (adapt the size of the RT-spot), drag the handles so that they are not too close to the border of the defect (this will make the transition less noticeable). Then: a) decrease “Transition” towards lower values; b) check “Lightness - Contrast “Super”; c) adjust “Lightness” and “Chrominance” as needed to bring the defect area closer to the unaffected area; d) if needed adjust slightly “Scope” to achieve the best result.&lt;br /&gt;
&lt;br /&gt;
===Using the “Contrast by detail levels” module===&lt;br /&gt;
When the sensor is dirty (grease), and when the affected area is large or if there are multiple small defects, “Contrast by detail levels” may be used, working as a sort of “wavelet” tool on luminance, and if needed on chrominance. In such cases: a) place the RT-spot on one of the stronger defects (adjust the size as needed); b) drag the handles so as to cover most of the affected area; c) set “Transition” to higher value; d) activate “Contrast by detail levels” and decrease the contrast of levels 3 and 4 (or lower); you can adjust the “Chroma” slider if needed.&lt;br /&gt;
&lt;br /&gt;
==Settings in the Preferences dialog==&lt;br /&gt;
Below is a list of the settings (already mentioned above in several places) which can be accessed from the “Preferences” dialog:&lt;br /&gt;
* In “Preferences” &amp;gt; “General” tab &amp;gt; “Local adjustments”, by checking the “Show spot delimiters” checkbox, an approximate zone delimitation is drawn which helps viewing the area affected by the RT-spot and its settings.&lt;br /&gt;
* If your images generally have low noise, you can set the default for “Global quality” to “Standard”, and get a significant speedup in processing time. This setting is found under “Preferences” &amp;gt; “Performance &amp;amp; Quality” tab &amp;gt; “Local adjustments”. The three choices for quality are selected from the “Local adjustments Quality method” combobox. Default is “Enhanced + chroma denoise”.&lt;br /&gt;
* Regarding “mip” files:&lt;br /&gt;
** the choice for “mip” files destination folder is set from “Preferences” &amp;gt; “Image processing” tab &amp;gt; “Mip Profiles”;&lt;br /&gt;
** in order to clean the generated “mip” profiles, go to “Preferences” &amp;gt; “File Browser” tab &amp;gt; “Cache Options” and click on the “Clear mip” button and/or “Clear pp3” – this is valid in the case where you chose to store “mip” files in the cache, otherwise if you chose to let RT write the “mip” files next to the input file, you will have to delete them manually. Note that the presence of older versions of “mip” and “pp3” files may lead to instability or even crashes of RawTherapee.&lt;br /&gt;
&lt;br /&gt;
==Processing time and memory use==&lt;br /&gt;
At image export time (output to JPG, TIFF…), for the “normal” mode, the algorithms compute the data only for in the RT-spot delimited areas, not for the whole image. Thus, processing time and memory stay reasonable. Note that of course, this will depend on the number of RT-spots, their size, and the type(s) of treatment done in these RT-spots.&lt;br /&gt;
&lt;br /&gt;
Excluding “Denoise” and “Sharpen”, processing time is in the order of a few tenths of a second per RT-spot, and memory use of a few hundred MB.&lt;br /&gt;
&lt;br /&gt;
Two settings have a strong influence on resource use:&lt;br /&gt;
* “Denoise” which adds around 1 sec. of processing time, and 1 MB of memory use;&lt;br /&gt;
* “Global quality: Enhanced + chroma denoise” which adds around 0.5 sec. And 0.6 MB.&lt;br /&gt;
These figures depend on the size of the RT-spot.&lt;br /&gt;
&lt;br /&gt;
==Future evolution==&lt;br /&gt;
Besides usual tweaking, bug corrections, improvements (settings, user interface)… it would be desirable to improve the GUI with regards to the creation/selection/modification of individual RT-spots.&lt;br /&gt;
&lt;br /&gt;
From a programming point of view, it should be possible to improve code readability and maintainability, and to integrate all the “mip” files code parts (as done in “rgbproc.cc”) which currently are linearly integrated to void procedures in “improccoordinator.cc”, “dcrop.cc” and “simpleprocess.cc”.&lt;/div&gt;</summary>
		<author><name>Sguyader</name></author>
	</entry>
	<entry>
		<id>http://rawpedia.rawtherapee.com/index.php?title=Local_Lab_Controls&amp;diff=3350</id>
		<title>Local Lab Controls</title>
		<link rel="alternate" type="text/html" href="http://rawpedia.rawtherapee.com/index.php?title=Local_Lab_Controls&amp;diff=3350"/>
		<updated>2017-11-20T00:10:33Z</updated>

		<summary type="html">&lt;p&gt;Sguyader: /* Processing time and memory use */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What kind of local control?==&lt;br /&gt;
&lt;br /&gt;
Several types of local control exist in mainstream applications :&lt;br /&gt;
# “lasso”, associated with layers and fusion masks (e.g. Photoshop©). This kind of control is widespread (Photoshop, Gimp, Darktable…) and users tend to favor those, at the expense of the type described in 3. below, which is less well known;&lt;br /&gt;
# dedicated tools for the removal of image defects such as “red eyes”, or “spots” associated with sensor imperfections or dirt;&lt;br /&gt;
# “U-points” controls, used until recently in Nikon Capture NX2©, or as an add-on to other software such as Nik Software©. For those (rare now) who tried such programs, there’s no way turning back to layers and fusion masks! This type of local control requires learning something different, and a cognitive “reprogramming”. In my opinion, this kind of local control is globally more efficient.&lt;br /&gt;
&lt;br /&gt;
The algorithm developed in the current version of RawTherapee is close in its principle to the U-points described above. Of course, the code used in Nik Software is not disclosed, but several years ago I was attracted by the simplicity of use and the efficiency of U-points, and I started developing a product which would use neither lassos, nor layers or fusion masks. Of course, nothing prevents us from having all 3 types of local control in the same program.&lt;br /&gt;
&lt;br /&gt;
The current version of the filter is perfectible, particularly regarding the user interface (GUI):&lt;br /&gt;
* for managing and viewing the RT-spots (control spots) on screen,&lt;br /&gt;
* for manipulating the different sliders, which would ideally be better if integrated to the actual control points, as done in Nik Software.&lt;br /&gt;
&lt;br /&gt;
However, those two aspects don’t harm everyday use, nor code portability.&lt;br /&gt;
&lt;br /&gt;
In order to improve manipulation and avoid long menus on screen, I added a GUI interface which is similar to the one used in the Wavelet tab, with “expanders”. Thus for each module (“Color and Light”, “Blur”, “Retinex”, …) you can choose to:&lt;br /&gt;
# display (or not) the full list of commands: sliders methods, curves…&lt;br /&gt;
# activate (or not) all the functions of the module.&lt;br /&gt;
&lt;br /&gt;
Warning: The second choice activates or cancels all the RT-spots. (It would be possible in theory to add this capability to every single RT-spot, but for what purpose?)&lt;br /&gt;
&lt;br /&gt;
===Lab and RGB local controls===&lt;br /&gt;
* The first algorithms are coded in L*a*b* mode with the following modules: “Color and Light”, “Blur / Add noise”, “Retinex”, “Tone mapping”, “Sharpen”, “Contrast by Detail Levels”, “Denoise”. Two additional modules have been added: “Exposure” and “Vibrance”.&lt;br /&gt;
* See below for the principles of the different algorithms, but one key point to remember for shape detection and artifact limitation, is that the Lab mode preserves the “hue” tint, which is crucial.&lt;br /&gt;
* The idea of an “RGB” module comes to one’s mind, with ''a minima'':&lt;br /&gt;
** a “White balance” module, which would allow to locally adjust the white balance, for example to warm up shadows, or to deal with mixed scene lighting such as “daylight” and “tungsten”. This module needs to be inserted just after “demosaic”.&lt;br /&gt;
&lt;br /&gt;
====Auto White balance====&lt;br /&gt;
The “White balance” module (in the “autowblocal” branch) serves two purposes:&lt;br /&gt;
* allowing a local adjustment of the white balance (of course)&lt;br /&gt;
* testing new algorithms for automatic white balance adjustment:&lt;br /&gt;
** in general use (full image), in order to achieve better results than with the current algorithm. Of course one will tell me that I should create a specific branch for “White balance”, but here I’m trying to hit two targets with one bullet.&lt;br /&gt;
&lt;br /&gt;
As a reminder, I’ve been asked in 2012 and 2013 to develop an iterative white balance “Auto Robust WB[http://ieeexplore.ieee.org/document/1649677/]”. At that time, another developer and I had spent a lot of time on this for an unsatisfactory result, so we gave up. Since then, benefiting from this experience, I resumed this work but in the reverse way! Now, if I’m correct, the algorithm works. I took advantage of this new capability (currently working on raw images only) to search in the academic literature for other auto WB algorithms. I found, and developed two new algorithms:&lt;br /&gt;
* “auto edge”[https://www.researchgate.net/publication/301419990_A_Method_to_Improve_Robustness_of_the_Gray_World_Algorithm]: the idea is to create an accentuation mask allowing to reinforce parts of the image where details are more prevalent, compared to flatter regions.&lt;br /&gt;
* “auto standard deviation”[http://www.acad.bg/rismim/itc/sub/archiv/Paper3_1_2012.pdf]: here, the image (or part of it for the local control) is divided in 12 zones, for each of which mean and standard deviation are computed, and the result assembled.&lt;br /&gt;
A third algorithm, “Color by correlation”[https://courses.cs.washington.edu/courses/cse467/08au/labs/l5/whiteBalance.pdf], looks promising but I’m facing several difficulties. After many trials of many types, the results are just too erratic…&lt;br /&gt;
&lt;br /&gt;
I also added the notion of gamma:&lt;br /&gt;
* the same principles which deal with luminance distribution – gamma sRGB – used in the main RawTherapee code.&lt;br /&gt;
&lt;br /&gt;
Bear in mind that the automatic white balancing is a totally non deterministic mathematical problem. The algorithms may perform more or less well (and faster or slower), but a perfect result can’t exist! Why is it so? If one is referring to the principles of color management ([http://rawpedia.rawtherapee.com/Color_Management_addon/fr#Balance_des_blancs]), it is necessary to have knowledge of the three of: the coloured object, the illuminant and the observer. At least two of those are unknown in practice. In addition, the environment in which an image is shot is not known while it has an effect on the perception (CIECAM), and the same is true during both image editing and viewing. The mission is thus almost impossible!&lt;br /&gt;
&lt;br /&gt;
The aim of the “White balance” module is '''for testing the algorithms''', there are 7 of them at least, and twice that number if “gamma sRGB” is considered. Indeed, in order to circumvent the obstacles encountered five years ago, instead of the using the image before demosaicing, I used the image just after demosaicing, allowing to apply (or not) “gamma sRGB”, ending in the same conditions as in normal use (but without normal “White balance” and “ICC or DCP” profile).&lt;br /&gt;
&lt;br /&gt;
Ideally, we should test the algorithms on many images, as well: which algorithm(s) to keep and implement in normal – global RGB – mode (maybe one or two, in addition to the current algorithm which we should keep for compatibility).&lt;br /&gt;
&lt;br /&gt;
====Local control of White balance====&lt;br /&gt;
The local control is currently limited to 1 spot only, but there’s no difficulty to increase this if users want so… while waiting for the evolution of “locallab”.&lt;br /&gt;
&lt;br /&gt;
Of course, I hear voices say “it doesn’t work”, or “the output doesn’t match with the preview”. But it does work! And it is more than evident that matching exactly the preview is by definition almost impossible… (differences between shadows, sun light, different illuminants, etc…) whatever the relevance of the algorithm.&lt;br /&gt;
&lt;br /&gt;
==What are the challenges we need to solve?==&lt;br /&gt;
Several general issues need to be solved so as to achieve smoothness in use:&lt;br /&gt;
* allow an (almost) unlimited number of RT-spots (the name we chose for the control spots in RawTherapee);&lt;br /&gt;
* adapt the local algorithms to be aware of scale, because many of them take the image size – the treated area – into account. This aspect is fundamental, particularly with curves which act on the whole image;&lt;br /&gt;
* minimise memory use and computation time for JPG and TIFF output;&lt;br /&gt;
* allow easy updates in case of evolution of either the algorithms or the number of methods/modules;&lt;br /&gt;
* optimise (minimise) the differences between the preview and the output.&lt;br /&gt;
* etc…&lt;br /&gt;
&lt;br /&gt;
For each RT-spot:&lt;br /&gt;
* allow for the action to occur, on user choice, either inside or outside (“Inverse” mode) of the selection area;&lt;br /&gt;
* allow shape detection, on user choice, in order to limit the action based on features/shapes;&lt;br /&gt;
* take care of the transition between the center of the treated area and the other parts of the image;&lt;br /&gt;
* etc…&lt;br /&gt;
&lt;br /&gt;
Currently, RT-spots are operational in Lab mode with the following modules and methods:&lt;br /&gt;
# “Colour and Light”: “Lightness”, “Chrominance”, “Contrast” in normal mode with 4 curves L=f(L), L=f(H), C=f(C), H=f(H), and in “inverse” mode;&lt;br /&gt;
# “Exposure”: normal mode only;&lt;br /&gt;
# “Vibrance:” normal mode only;&lt;br /&gt;
# “Blur &amp;amp; noise”: normal and “inverse” modes;&lt;br /&gt;
# “Retinex”: normal and “inverse” modes, now also with “transmission gain” curve;&lt;br /&gt;
# “Sharpening”: normal and “inverse” modes;&lt;br /&gt;
# “Contrast by detail levels” (CBDL): normal mode only;&lt;br /&gt;
# “Denoise”: normal mode only.&lt;br /&gt;
&lt;br /&gt;
==General principles==&lt;br /&gt;
===The RT-spot object===&lt;br /&gt;
As I mentioned earlier, the system used in RT is similar to the one developed in Nik Software, but with some significant differences:&lt;br /&gt;
* each RT-spot can be viewed as an object with a number of fields (about 70 as of today), made of sliders, curves, control points, etc…;&lt;br /&gt;
* each field, grouped in modules, can be activated or not, and have different parameter values according to their nature;&lt;br /&gt;
* the modules are made to be coherent for the user: “Color and Light”, “Exposure”, “Contrast”, “Vibrance”, “Blur”, “Retinex”, “Sharpening”, “Tone Mapping”, “Contrast by detail levels”, “Denoise”;&lt;br /&gt;
* the number of RT-spot objects can vary from 2 up to 500;&lt;br /&gt;
* data describing the RT-spot objects are stored in text files with .mip extension;&lt;br /&gt;
* creating, modifying and tracking of the RT-spot objects are done in a “for” loop;&lt;br /&gt;
* there’s no code duplication.&lt;br /&gt;
&lt;br /&gt;
===Partitioning into 4 zones – previewing the RT-spot area===&lt;br /&gt;
When the user selects an RT-spot, the screen preview shows:&lt;br /&gt;
* a centre, made of a circle whose diameter and position can be adjusted directly using the mouse or the sliders;&lt;br /&gt;
* two horizontal and two vertical handles, whose position can be modified directly using the mouse or the provided sliders, controlling the extent of the area affected by the RT-spot;&lt;br /&gt;
* if &amp;quot;Show spot delimiters&amp;quot; is checked in &amp;quot;Preferences&amp;quot; &amp;gt; &amp;quot;General&amp;quot; tab &amp;gt; &amp;quot;Local adjustments&amp;quot;, one can visualise approximately the area affected by the spot. Because I couldn’t work cleanly with the « arc/ellipse/scale » function in the Cairo graphics library, I made each quadrant defined by a pseudo-ellipse made of 3 Bézier curves joining each other. In most cases the approximation is satisfying… To help grabbing the 4 handles, I made them longer (the Bézier curves are inactive!).&lt;br /&gt;
&lt;br /&gt;
We obtain 4 zones, whose orientation cannot be modified (the default rotation angle is set to zero). Those 4 zones have each of their vertices connected by imaginary ellipses.&lt;br /&gt;
&lt;br /&gt;
It is possible to drag the handles outside the image preview area.&lt;br /&gt;
&lt;br /&gt;
It should be possible to replace the ellipse with a hand drawn curve (even if I think its usefulness is debatable because of the existence of the shape detection algorithm), as long as the homothetic transform of the curve doesn’t intersect with the original curve. Although the benefits from this intellectually satisfying “improvement” should negligible in the case of the RT-spots, it will be possible to make the current RT-spots and lasso type of controls coexist eventually.&lt;br /&gt;
&lt;br /&gt;
===The &amp;quot;normal&amp;quot; and &amp;quot;excluding&amp;quot; types of RT-spots===&lt;br /&gt;
Two types of RT-spots are available:&lt;br /&gt;
* &amp;quot;Normal&amp;quot;: these are the spots which do the local retouching. Each new RT-spot takes into account the effect of existing spots when their zone of influence overlap (a sort of recursive action).&lt;br /&gt;
* &amp;quot;Excluding&amp;quot;: adding a new &amp;quot;excluding&amp;quot; RT-spot allows to revert the effect created by a &amp;quot;normal&amp;quot; RT-spot in their overlapping zone of influence , from the original image data (but doing its calculations from the reference values of the area affected by the &amp;quot;normal&amp;quot; RT-spot).&lt;br /&gt;
&lt;br /&gt;
For both types, the user has access to most of the modules (&amp;quot;Color and Light&amp;quot;, &amp;quot;Contrast by detail levels&amp;quot;, &amp;quot;Blur&amp;quot;, ...)&lt;br /&gt;
&lt;br /&gt;
====Comments about the &amp;quot;excluding&amp;quot; RT-spot====&lt;br /&gt;
* The principle of the &amp;quot;excluding&amp;quot; spot is similar to the &amp;quot;counterpoint&amp;quot; in Capture NX2, and is useful when for example, the effect of a &amp;quot;normal&amp;quot; RT-spot bleeds into an area which the user wants to be unaffected. This unwanted effect happens when when the tints of the two areas (the area the user wants to be affected, and the area one wants to remain unaffected) are to close.&lt;br /&gt;
* The underlying algorithm is similar to the main algorithms used elsewhere in &amp;quot;locallab&amp;quot;, and is based on tint differences. While it's not perfect it should give satisfaction 70% of the time.&lt;br /&gt;
* I implemented an additional algorithm (with no guarantee that it will actually work one day) to help discriminate the areas, based on a Sobel-Canny transform. The transform is coded but is not yet accessible to the user, as I'm still working to make it more efficient.&lt;br /&gt;
&lt;br /&gt;
====How to use the &amp;quot;excluding&amp;quot; RT-spot, and its limitations====&lt;br /&gt;
# Create a new RT-spot over the area you want to restore.&lt;br /&gt;
# In the &amp;quot;Settings&amp;quot; panel, from the &amp;quot;Spot method&amp;quot; combobox choose &amp;quot;Excluding spot&amp;quot;.&lt;br /&gt;
# Adjust &amp;quot;Scope&amp;quot;, &amp;quot;Transition&amp;quot; and &amp;quot;Spot size&amp;quot; as well as the shape of the zone of influence using the 4 handles, until you get the desired reversion of the effect. You can use complimentary adjustments such as &amp;quot;Color and light&amp;quot;, etc.&lt;br /&gt;
The algorithm computes the reference values (tint, chroma, luma) from the the current image (see below). As a consequence, the &amp;quot;excluding&amp;quot; effect won't work if the image area is black (for example when the user uses a normal RT-spot using &amp;quot;Color and light&amp;quot; in inverse mode to create a black frame).&lt;br /&gt;
Sometimes, when the &amp;quot;inverse&amp;quot; mode is selected, the &amp;quot;excluding&amp;quot; spot algorithm may not work as expected and lead to a difference between the preview and the output (JPG, TIFF) image. Increasing the value of &amp;quot;Scope&amp;quot; of the &amp;quot;excluding&amp;quot; RT-spot should help in this situation.&lt;br /&gt;
&lt;br /&gt;
===Tint, chroma, luminance references and the algorithm principle in “normal” mode===&lt;br /&gt;
In order to develop an efficient shape detection algorithm:&lt;br /&gt;
* The central circle zone is used as the reference. Based on the diameter value chosen by the user, the algorithm computes the tint (hue), chroma and luminance averages.&lt;br /&gt;
* The choice of the central zone diameter depends on the use intent. For example, if working on a foliage area the user would benefit from choosing a smaller diameter value in order to select only the foliage green; in contrast, for skin tones the user should increase the diameter to avoid the detection of parasites (noise, eye lashes…).&lt;br /&gt;
* For each quadrant, depending on the the value of the “Scope” slider, the algorithm does:&lt;br /&gt;
# take into account the tint difference between the zone centre and the affected pixel;&lt;br /&gt;
# through a complex algorithm based on the deltaE notion (perceived difference between two colours, taking tint, chroma and luminance into account), decrease the amount of applied effect as a function of the difference between the central zone and the affected pixel;&lt;br /&gt;
# follow either a linear or a parabolic law to adjust the amount of applied effect, based on the specific the case.&lt;br /&gt;
&lt;br /&gt;
This allows adapting the amount of effect according to the above-mentioned criteria. For example, if the central circle is located on foliage, the action will be limited to the leaves, without touching the background (which would be impossible to obtain with the lasso type of controls). Additionally, if some other foliage resides within the area covered by the RT-spot, it will also be affected.&lt;br /&gt;
* Adjusting the value of the “Transition” slider modifies the transition of the effect (from the centre to the edge): on 50, the inner (linear) half will get the full 100% action/effect, while the effect in the outer half will gradually transition from 100% to 0% towards the edge;&lt;br /&gt;
* By increasing the value of “Scope”, progressively more of the selected area is taken into account, whatever the tint, chroma and luminance;&lt;br /&gt;
* Conversely, by decreasing the “Scope” value the effect will get limited to the pixels which are more similar (in terms of deltaE) to the reference zone.&lt;br /&gt;
&lt;br /&gt;
The shape detection algorithm works in “Normal” mode except for some modules (“Denoise”). It’s not implemented in “Inverse” mode, doing so would not make sense.&lt;br /&gt;
&lt;br /&gt;
The algorithm will see its performance increase when the user chooses “Enhanced” or “Enhanced + chroma denoise” in the “Global quality:” combobox. The second choice additionally applies a low amount of chroma noise reduction in order to get rid of artefacts which could be brought up by the “Enhanced” algorithm (note that the chroma denoise step increases memory use and computing time).&lt;br /&gt;
&lt;br /&gt;
The algorithm is used in full capacity for “scope” &amp;lt; 20.&lt;br /&gt;
&lt;br /&gt;
===Why no alternative algorithms?===&lt;br /&gt;
It should be possible to implement other shape detection algorithms than the deltaE-based one used currently, for example:&lt;br /&gt;
* edge detection algorithms such as “Canny” or “Sobel”;&lt;br /&gt;
* wavelet decomposition.&lt;br /&gt;
&lt;br /&gt;
But in both cases, everything would have to be done!&lt;br /&gt;
&lt;br /&gt;
===Functioning in “inverse” mode===&lt;br /&gt;
When it is available, the “Inverse” mode is extremely simplified: only the “Transition” slider can be used to apply the effect.&lt;br /&gt;
As of late October 2017, I devised a new method for “Inverse” mode. It is limited to the “Blur &amp;amp; Noise” module (see the corresponding section below).&lt;br /&gt;
&lt;br /&gt;
===Maximum number of RT-spots===&lt;br /&gt;
By default the number of available RT-spots is 8. You can choose any number between 2 and 499. For this you only need to change the parameter “Nspot” in the “options” file (for example: Nspot=12). Restart RawTherapee for the modification to be taken into account.&lt;br /&gt;
&lt;br /&gt;
===The “super” algorithm===&lt;br /&gt;
The key to “success” was the algorithm implemented in late January 2017, which works this way:&lt;br /&gt;
# on the pixel data which are within the area covered by the RT-spot, the algorithm applies either a “traditional” curve, a slider, or a normal transfer function (“Retinex”, “Tone Mapping”, “Contrast by detail levels”, “Vibrance”, …);&lt;br /&gt;
# the LUT or the transfer function is converted into an equivalent of a slider, separating negative and positive values so that the function can be viewed as multiple sliders (as many sliders as there are pixels) in the -100, 0, +100 interval;&lt;br /&gt;
# the data are passed to the shape detection function – the 4 quadrants. For every pixel, the difference in terms of tint, chroma and luma is computed with regards to the central reference. The linear variation equations are estimated for luminance (L=f(L)), chroma (C=f(C)) or transfer functions;&lt;br /&gt;
# different corrections are applied to account for the environment (sky, skin tones…)&lt;br /&gt;
# a correction is made (with threshold and iterations) in order to avoid correcting (or only slightly, based on the user’s choice) the grey or neutral tones which are in the same tint as the reference (but with a low chroma value);&lt;br /&gt;
# the parameters are weighted based on the shape of the RT-spot (ellipses) and the transition zone;&lt;br /&gt;
# the values of the “Global quality:” parameters are important, particularly so for images with a low amount of noise – chroma noise is interpreted by the algorithm being of the same colour as the spot. It is thus necessary to suppress this noise, that is the purpose of “Enhanced + chroma denoise” (this algorithm may not be sufficient, though – in this case using the local “Denoise” module may be useful).&lt;br /&gt;
&lt;br /&gt;
This new (“super”) algorithm seems to perform generally well, but in the event when the RT-spot is located in a grey/neutral or flat area, the algorithm may fail. In such cases, using the old algorithm is recommended (except for “Retinex”, “Tone Mapping” and “Contrast by detail levels” for which it is made unavailable for the sake of code simplicity).&lt;br /&gt;
&lt;br /&gt;
===Artefact reduction and the “Global quality” algorithms===&lt;br /&gt;
By default, “Global quality:” is set to “Enhanced + chroma denoise”. Whereas it increases computation time, it is still generally preferable. In case one wants a more responsive preview, “Enhance” or “Standard” can be chosen (good for exploring the image).&lt;br /&gt;
* two sliders allow reducing artefacts and improving the algorithm’s rendering. They work based on chroma, in neutral/gray tones. To completely remove its effect, one can simply set “iterations=0”. These sliders may be used for &amp;quot;Color light&amp;quot;, &amp;quot;Exposure&amp;quot;, &amp;quot;Retinex&amp;quot;, &amp;quot;Vibrance&amp;quot;, &amp;quot;Tone mapping&amp;quot; and &amp;quot;Contrast by detail levels&amp;quot;;&lt;br /&gt;
* for (even slightly) noisy images, the algorithms may be misled. In this case it is recommended to keep &amp;quot;Global quality:”  set to “Enhanced + chroma denoise&amp;quot;, and (sometimes) activate the local “Denoise” module and adjust the sliders very gently (including “Luminance”);&lt;br /&gt;
* under some circumstances, with “Tone Mapping” for example, the artefact reduction algorithm may actually generate more artefacts. When it happens, set “iterations=0”.&lt;br /&gt;
&lt;br /&gt;
If your images are generally clean (no or very low noise), you can choose to have “Standard” as the default for “Global quality:” – this will speed up the image processing. To do so, go to “Preferences” &amp;gt; “Performance and quality” tab &amp;gt; “Local adjustments” and choose the “Standard” algorithm among the 3 options. This will become the new default  when new RT-spots are created, but of course the algorithm can still be changed on the fly by choosing from the “Global quality” combo box.&lt;br /&gt;
&lt;br /&gt;
===Avoid color shift===&lt;br /&gt;
The “Avoid color shift” checkbox serves two purposes:&lt;br /&gt;
* put the colours within the current working profile gamut, using a relative colorimetry;&lt;br /&gt;
* adjust colours using a “Munsell” correction – particularly for red-orange and blue-purple colours, when saturation in the L*a*b* space has changed significantly.&lt;br /&gt;
&lt;br /&gt;
===“mip” files – Principles of the multi-point algorithm===&lt;br /&gt;
For the local control system to work and keep track of RT-spot objects, a text file – similar to a pp3 – is written in 2 possible places:&lt;br /&gt;
* next to the edited image file. If, for example, you edit an image named ASC4509.NEF, a new file named ASC4509.NEF.mip will be generated in the same folder. In this case, several sessions can be open for the same image, as long as copies of the image are stored in different folders. However, the folder names in the path have to contain ASCII characters only, otherwise it will make the program crash;&lt;br /&gt;
* in the dedicated “mip” folder, within the “cache” directory (through an MD5 hash number which identifies the file). This is the default. If chosen, when multiple copies of the same file exist in distinct folders, editing them creates as many “mip” files. This option allows the use of non ASCII characters in the folder names and path.&lt;br /&gt;
&lt;br /&gt;
The choice between these two behaviours is made in “Preferences” &amp;gt; “Image processing” tab &amp;gt; “Mip profiles”.&lt;br /&gt;
&lt;br /&gt;
The “mip” files contain the data which are passed to RawTherapee through processes of the “procparams” type, and LUTs which allow editing in zoom mode. When updating RawTherapee to a new version, it may be required to delete the “mip” files (or the whole cache) to avoid a potential crash of the application. This can be achieved by going to “Preferences” &amp;gt; “File browser” tab, then choosing “Clear mip” and/or “Clear pp3” – all this is valid only if “mip” and “pp3” files have been set to be saved to the cache folder, otherwise they will have to be manually deleted from the working folder. Keeping older “mip” and “pp3” files may lead to instability or crashes of the application.&lt;br /&gt;
&lt;br /&gt;
====Architecture of the filter====&lt;br /&gt;
When I “ventured” into a multi-point, no-layer and no-mask system, code duplication had to be avoided. Indeed, it is unthinkable to consider, for 10 RT-spots, generating 10 GUI code blocks, and just as many code blocks in “rtengine”. After careful consideration, the idea was to have a file updating and tracking in real time – i.e. a file which would follow each modification made by the user – the actions/modifications history.&lt;br /&gt;
&lt;br /&gt;
Of course, the parameters used by RawTherapee for the GUI and for the main code through “params” are of different types:&lt;br /&gt;
* numeric: integer, float, double,…&lt;br /&gt;
* Boolean&lt;br /&gt;
* string (in choice menus for the different modules)&lt;br /&gt;
* curves, through “vectors” of type double with dynamic dimension&lt;br /&gt;
* …&lt;br /&gt;
&lt;br /&gt;
====Data conversion====&lt;br /&gt;
In order to simplify data management, the first step is to convert all data to integers. Sometimes this can lead to a slight precision loss, which I think is negligible.&lt;br /&gt;
* This operation is very simple for numeric values, even though in some cases (such as hue, which is expressed in radian in the interval [-Pi, +Pi]) it needs a double “float*100 and /100 conversion to keep precision.&lt;br /&gt;
* It is logical for Boolean operations and methods.&lt;br /&gt;
* However, it is a complex matter regarding curves. The values to be recorded in the “mip” file are of type vector&amp;lt;double&amp;gt;, in a dynamic table of numeric values. There may be a simpler way, by using existing functions from “procparams”, but I didn’t succeed. &lt;br /&gt;
Nevertheless, I could get around this by:&lt;br /&gt;
# converting doubles to integers with 3 significant figures – which is largely enough,&lt;br /&gt;
# then converting the “vector” to a variable length character string,&lt;br /&gt;
# the writing and reading of this character string and converting to a vector dynamically using an appropriate function (”strcurv_data”). Note that this function allows adjusting the curves within the limit of 16 inflection points (Bézier curve) for the flat curve, and 32 points for the diagonal, which should be enough. Whether this would not be enough, it should be possible to increase that number, though compatibility would be compromised.&lt;br /&gt;
&lt;br /&gt;
====Some elements about curves====&lt;br /&gt;
The implementation of curves has been a complex task, particularly since:&lt;br /&gt;
# each curve needs its own reset function – resize() at each iteration,&lt;br /&gt;
# which implies oddities regarding their description, for example the diagonal curve gets initialised with several points, despite it looks being “empty”. This is mandatory for correct functioning, but this means that the curve is always open/active. Consequently, to avoid some unwanted loss of computation time in “preview” mode, the user has to activate the curve by clicking on the “curves” combobox. The same activation is necessary for L=f(H) and C=f(C) curves. While clicking enabling the “curves” (linear) would seem to be a better solution, it didn’t work despite many trials.&lt;br /&gt;
# during all the procedure, we need to set each &amp;quot;params&amp;quot; value to &amp;quot;clear&amp;quot; for curves, for each LUT, at each iteration and then through a &amp;quot;vector&amp;quot; to reassign the good, updated values to &amp;quot;curve params&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
====Data storing and dynamic use====&lt;br /&gt;
Once data have been converted:&lt;br /&gt;
* they are stored in a text (mip) file,&lt;br /&gt;
* each one is referenced inside a 2-dimension dynamical table:&lt;br /&gt;
# dataspot[x][y] for numeric and boolean values and methods, where “x” is the representative index of the parameter (e.g. “9” is for “lightness”) and “y” represents the current RT-spot (control spot). Value “0” represents the current in-use value (the one stores in “params”).&lt;br /&gt;
# retistr[y], llstr[y], lhstr[y], ccstr[y], hhstr[y], skinstr[y], pthstr[y], exstr[y] for parameters of type “curve”. Currently there are only 8 parameters, used for local “Retinex”, “Color and light” (L=f(L), C=f(C), L=f(H), H=F(H)), “Vibrance” and “Exposure”, but it is easy to add more. “y” is used as above in 1.&lt;br /&gt;
&lt;br /&gt;
The way data are stored and used fits well with improccoordinator.cc (current management / preview) and simpleprocess.cc (TIFF / JPG  output) files, but not so with dcrop.cc and the partial display of the image (RawTherapee’s pipeline).&lt;br /&gt;
&lt;br /&gt;
In this case (zoom / preview) another solution had to be found in order to synchronise the modifications in real time. I made use of LUTs, so that to each entry referenced in the table described above a LUTi(z) is associated, with z=500 possible entries (500 corresponds to the current maximum number of RT-spots, but this limit can be decreased or increased). The LUTi “z” corresponds to the dataspot “y”. A 25,000 entries LUTi (arbitrary number) is used for “retistr”, “llstr”, “lhstr”, “ccstr”, “hhstr”, “skinstr”, “pthstr”, “exstr” for storing each “vector” curve value in memory (up to 69 values stored as integers).&lt;br /&gt;
&lt;br /&gt;
During data processing, exchanges occur between: params, dynamic tables and LUTi. The values used by dcrop.cc are dynamically linked to dynamical tables by parent→.&lt;br /&gt;
&lt;br /&gt;
====Exchange processes and dynamic data storing====&lt;br /&gt;
# reading of the “mip” file to check the version number and guide the updates&lt;br /&gt;
# creating the “mip” file if it doesn’t exist&lt;br /&gt;
# storing the data in LUTi and dynamic tables from the values stored in “params” (index 0 values)&lt;br /&gt;
# first interactive update with the GUI through a transfer function between “rtengine” and locallab.cc (aloListener → localretChanged). This is one of the 3 functions required for the process to work correctly&lt;br /&gt;
# reading of the “mip” file and data storing in dynamic tables (index values ==&amp;gt; y) according to the number of RT-spots&lt;br /&gt;
# creating a loop – according to the number of RT-spots – which updates LUTi (required by “dcrop”) and “params” values from values stored in the dynamic tables&lt;br /&gt;
# call to the “Lab_local” function which contains the algorithms controlling each RT-spot (luminance, sharpness, retinex, denoise, …)&lt;br /&gt;
# second interactive update with the GUI through another transfer function between “rtengine” and “locallab.cc”&lt;br /&gt;
# treatment of the current RT-spot by using the index (0) values from the dynamic tables. These values are attributed to 1) “params”, 2) LUTi and 3) current index values&lt;br /&gt;
# call to the “Lab_local” function for the current RT-spots&lt;br /&gt;
# saving to the “mip” file.&lt;br /&gt;
&lt;br /&gt;
Note that if the user modifies the curve (amplitude, number of inflection points) a third interactive update is made in order to conform all of the data according to events.&lt;br /&gt;
&lt;br /&gt;
====A few unavoidable “fantasies”====&lt;br /&gt;
Of course everything looks simple, the process works if, and only if, all the data are dynamically updated. I’ve tried a lot, went groping, and finally found a working solution… but an uncanny one. There’s probably a more “informatically” correct way to do it, but at this point I’ve done as explained above and hereafter.&lt;br /&gt;
&lt;br /&gt;
The 3 exchanges between “rtengine” and the GUI occur with 3 parameters which actually do nothing in the program except doing the update process:&lt;br /&gt;
# “anbspot” which takes values of 0 or 1&lt;br /&gt;
# “cTgainshaperab” (curve) which takes any value bewteen 0.70 and 0.90&lt;br /&gt;
# “retrab” which varies around 500.&lt;br /&gt;
I have added 3 more parameters (in the form of sliders) – hueref, chromaref and lumaref – hidden from the user but which are used to update the system in real time, to correctly take into account the reference “spot” values. Allowing those 3 parameters to vary brings stability and allows real time updates. Increasing the number of those “fantasy” parameters should not be necessary. These extra parameters are hidden to the user, and are only visible in the history.&lt;br /&gt;
&lt;br /&gt;
In addition, I had to add some empirical time delays, giving time to time… Time delay is used for example when the user modifies the curve (amplitude, number of inflection points).&lt;br /&gt;
&lt;br /&gt;
==Specificity of the local mode (as compared to “Lab adjustments”)==&lt;br /&gt;
Hereafter is some useful information for the user, often specific to the local mode.&lt;br /&gt;
&lt;br /&gt;
===Color and Light===&lt;br /&gt;
* The algorithms used for luminance and contrast in local mode differ from the ones used in “Lab adjustments”, which may lead to differences in rendering.&lt;br /&gt;
* The luminance algorithm is made such that below -90 and down to -100 for “Lightness”, it is possible to increase the image's “darkness”, almost to the point of getting a luminance value close to 0. To accentuate this effect, “Chrominance” can be decreased and “Scope” increased.&lt;br /&gt;
* The inverse mode can be used for creating graduated frames. If “Ligthness” is set to -100 and &amp;quot;Chrominance&amp;quot; is reduced, the “frame border” will be black.&lt;br /&gt;
* For the “Lightness” and “Contrast” sliders, the user can choose among 2 algorithms: the first one (default) is close to that in “Lab adjustments” while the second one, activated through “Lightness - Contrast ‘Super’” is close to the algorithm used for the L=f(L) “Super” curve.&lt;br /&gt;
* Do not hesitate, when needed, to activate “Enhanced” or “Enhanced + chroma denoise” in the “Global Quality:” combobox.&lt;br /&gt;
&lt;br /&gt;
====Curves====&lt;br /&gt;
* An L=f(L) or C=f(C) curves allow controlling the luminance and chrominance for each RT-spot as a function of luminance or chrominance.&lt;br /&gt;
* An L=f(H) curve allows controlling the luminance for each RT-spot as a function of tint.&lt;br /&gt;
* An H=f(H) curve allows controlling the tint for each RT-spot as a function of tint.&lt;br /&gt;
The curves are activated by selecting one of the two algorithms from the “Curves types” combobox:&lt;br /&gt;
* “Normal”: the curves – particularly the one that is the most difficult to manage, L=f(L) – use an algorithm close to the one used with the sliders (Normal mode),&lt;br /&gt;
* “Super”: using a new algorithm, which I think performs very well (it even surprised me the first time I used it).&lt;br /&gt;
&lt;br /&gt;
Caution: when the RT-spot resides in an area which is neutral, grey or very uniform, the artefacts introduced by the new algorithm (“Super” algorithm for the curve or the slider) may be impossible to get rid of. Use one of the 2 older algorithms to avoid that.&lt;br /&gt;
&lt;br /&gt;
===Exposure===&lt;br /&gt;
The “Exposure” module may look like the the one in global RGB mode, but:&lt;br /&gt;
* it works entirely in L*a*b* mode, hence the differences in rendering;&lt;br /&gt;
* there’s no “Lightness”, “Chroma” or “Contrast” slider, whose functions are already fulfilled in the “Color and Light” module;&lt;br /&gt;
* there’s only one “Contrast” curve, similar to the L=f(L) firm “Color and Light”. Of course its effect is different from “Tone curve” which works in RGB mode. If needed, two L=f(L) curves can be activated, one under “Color and Light” and the other under “Exposure”.&lt;br /&gt;
&lt;br /&gt;
===Vibrance===&lt;br /&gt;
This module is similar to the main one (from RawTherapee's &amp;quot;Exposure&amp;quot; tab).&lt;br /&gt;
&lt;br /&gt;
===Blur &amp;amp; Noise===&lt;br /&gt;
“Blur” is activated only when “Radius” =&amp;lt; 2.&lt;br /&gt;
By significantly lowering the default value of “Scope” and possibly checking “Blur luminance only”, it is possible to get a different amount of blur for the different tints.&lt;br /&gt;
Since October 2017, 3 methods are proposed:&lt;br /&gt;
* “Normal”: the shape detection algorithm has been improved, it is now closer to shape detection algorithm proposed in the other modules;&lt;br /&gt;
* “Inverse”: a simplified algorithm, which doesn’t make use of “Scope”. The inversion is coarse and doesn’t allow a fine separation between the affected and unaffected areas;&lt;br /&gt;
* “Symmetric”: this new algorithm uses the same processes as “Normal”, and adjusting “Scope” the user can target the process with more precision.&lt;br /&gt;
Caution: &lt;br /&gt;
* Using the “Inverse” mode will blur large portions of the image, which can not be corrected later on.&lt;br /&gt;
* The action of “Scope” may sometimes appear puzzling: for instance, in a portrait, the eyes (which of course differ from the skin) may be blurred if the value of “Scope” is too low.&lt;br /&gt;
&lt;br /&gt;
===Tone Mapping===&lt;br /&gt;
Caution when uniformly coloured areas (sky, grey/neutral zones) have a similar tint to the area on which the RT-spot is placed. In cases where this leads to artefacts, set the “Iterations” slider to 0 in “Settings” &amp;gt; “Reduce artefacts – Improve algorithm”.&lt;br /&gt;
&lt;br /&gt;
===Retinex===&lt;br /&gt;
Compared to the standard “Retinex” module, the local “Retinex module has simplified controls, and is applied at the end of the pipeline instead of the beginning. Since “mip” version 10002, the “Transmission gain” is specific to each RT-spot.&lt;br /&gt;
&lt;br /&gt;
===Sharpening===&lt;br /&gt;
Only the “RL Deconvolution” algorithm is provided here.&lt;br /&gt;
&lt;br /&gt;
===Contrast by detail levels===&lt;br /&gt;
Compared to the main RGB mode module, this one has:&lt;br /&gt;
* 5 levels instead of 6,&lt;br /&gt;
* no slider for “skin tone” protection (not needed since the algorithm works locally on the RT-spot area),&lt;br /&gt;
* an additional “Chroma” slider.&lt;br /&gt;
&lt;br /&gt;
Caution when uniformly coloured areas (sky, grey/neutral zones) have a similar tint to the area on which the RT-spot is placed. In cases where this leads to artefacts, set the “Iterations” slider to 0 in “Settings” &amp;gt; “Reduce artefacts – Improve algorithm”.&lt;br /&gt;
&lt;br /&gt;
===Denoise===&lt;br /&gt;
Compared to the main RGB mode module, this one has:&lt;br /&gt;
* only the wavelet tool working (no Fourier function, nor medians),&lt;br /&gt;
* less sliders and curves,&lt;br /&gt;
* the possibility to work differentially on fine or coarse noise for both luminance and chrominance noise.&lt;br /&gt;
&lt;br /&gt;
==A specific use case : reduction of image defects (dirty sensor, red eyes, …)==&lt;br /&gt;
“Locallab” had not been thought with the idea of correcting small image defects. However, some visible, “photographically disturbing” defects may actually be tamed or even removed. Of course, this is not incompatible with other more specialised modules which could be introduced (or not) into “Locallab”… At least 3 existing modules can serve this purpose, alone or in combination, by adapting their use:&lt;br /&gt;
* “Color and Light” for spot-like defects;&lt;br /&gt;
* “Contrast by detail levels” for spread out defects;&lt;br /&gt;
* “Blur and Noise” as an optional complement (caution, this is a destructive action, use moderately).&lt;br /&gt;
&lt;br /&gt;
These modules can be used either on the main image (raw, TIFF,  …) or on a flat-field image.&lt;br /&gt;
&lt;br /&gt;
===Using the “Color and Light” module===&lt;br /&gt;
* Activate “Color and Light”&lt;br /&gt;
* A red eye removal tool equivalent can be obtained by framing closely around the eye – central circle zone centered on the eye’s red, spot handles close to the eye – low “Scope” value, then lowering “Lightness” and “Chrominance” to -100.&lt;br /&gt;
* The same idea allows reducing the “IR spot” kind of defect by framing closely around the defect – central circle zone centred on the defect, spot handles close to the defect area – then lowering “Chrominance” to taste, and if needed lowering the “scope” value.&lt;br /&gt;
* In some (simple) situations, a “dirty sensor” defect can be reduced, in particular in the case of “sensor grease”. It can be seen as stains or spots on a uniform background. To attenuate this, choose a tight framing of around the defect – central circle on the centre of the defect (adapt the size of the RT-spot), drag the handles so that they are not too close to the border of the defect (this will make the transition less noticeable). Then: a) decrease “Transition” towards lower values; b) check “Lightness - Contrast “Super”; c) adjust “Lightness” and “Chrominance” as needed to bring the defect area closer to the unaffected area; d) if needed adjust slightly “Scope” to achieve the best result.&lt;br /&gt;
&lt;br /&gt;
===Using the “Contrast by detail levels” module===&lt;br /&gt;
When the sensor is dirty (grease), and when the affected area is large or if there are multiple small defects, “Contrast by detail levels” may be used, working as a sort of “wavelet” tool on luminance, and if needed on chrominance. In such cases: a) place the RT-spot on one of the stronger defects (adjust the size as needed); b) drag the handles so as to cover most of the affected area; c) set “Transition” to higher value; d) activate “Contrast by detail levels” and decrease the contrast of levels 3 and 4 (or lower); you can adjust the “Chroma” slider if needed.&lt;br /&gt;
&lt;br /&gt;
==Settings in the Preferences dialog==&lt;br /&gt;
Below is a list of the settings (already mentioned above in several places) which can be accessed from the “Preferences” dialog:&lt;br /&gt;
* In “Preferences” &amp;gt; “General” tab &amp;gt; “Local adjustments”, by checking the “Show spot delimiters” checkbox, an approximate zone delimitation is drawn which helps viewing the area affected by the RT-spot and its settings.&lt;br /&gt;
* If your images generally have low noise, you can set the default for “Global quality” to “Standard”, and get a significant speedup in processing time. This setting is found under “Preferences” &amp;gt; “Performance &amp;amp; Quality” tab &amp;gt; “Local adjustments”. The three choices for quality are selected from the “Local adjustments Quality method” combobox. Default is “Enhanced + chroma denoise”.&lt;br /&gt;
* Regarding “mip” files:&lt;br /&gt;
** the choice for “mip” files destination folder is set from “Preferences” &amp;gt; “Image processing” tab &amp;gt; “Mip Profiles”;&lt;br /&gt;
** in order to clean the generated “mip” profiles, go to “Preferences” &amp;gt; “File Browser” tab &amp;gt; “Cache Options” and click on the “Clear mip” button and/or “Clear pp3” – this is valid in the case where you chose to store “mip” files in the cache, otherwise if you chose to let RT write the “mip” files next to the input file, you will have to delete them manually. Note that the presence of older versions of “mip” and “pp3” files may lead to instability or even crashes of RawTherapee.&lt;br /&gt;
&lt;br /&gt;
==Processing time and memory use==&lt;br /&gt;
At image export time (output to JPG, TIFF…), for the “normal” mode, the algorithms compute the data only for in the RT-spot delimited areas, not for the whole image. Thus, processing time and memory stay reasonable. Note that of course, this will depend on the number of RT-spots, their size, and the type(s) of treatment done in these RT-spots.&lt;br /&gt;
&lt;br /&gt;
Excluding “Denoise” and “Sharpen”, processing time is in the order of a few tenths of a second per RT-spot, and memory use of a few hundred MB.&lt;br /&gt;
&lt;br /&gt;
Two settings have a strong influence on resource use:&lt;br /&gt;
• “Denoise” which adds around 1 sec. of processing time, and 1 MB of memory use;&lt;br /&gt;
• “Global quality: Enhanced + chroma denoise” which adds around 0.5 sec. And 0.6 MB.&lt;br /&gt;
These figures depend on the size of the RT-spot.&lt;br /&gt;
&lt;br /&gt;
==Future evolution==&lt;br /&gt;
Besides usual tweaking, bug corrections, improvements (settings, user interface)… it would be desirable to improve the GUI with regards to the creation/selection/modification of individual RT-spots.&lt;br /&gt;
&lt;br /&gt;
From a programming point of view, it should be possible to improve code readability and maintainability, and to integrate all the “mip” files code parts (as done in “rgbproc.cc”) which currently are linearly integrated to void procedures in “improccoordinator.cc”, “dcrop.cc” and “simpleprocess.cc”.&lt;/div&gt;</summary>
		<author><name>Sguyader</name></author>
	</entry>
	<entry>
		<id>http://rawpedia.rawtherapee.com/index.php?title=Local_Lab_Controls&amp;diff=3349</id>
		<title>Local Lab Controls</title>
		<link rel="alternate" type="text/html" href="http://rawpedia.rawtherapee.com/index.php?title=Local_Lab_Controls&amp;diff=3349"/>
		<updated>2017-11-20T00:10:04Z</updated>

		<summary type="html">&lt;p&gt;Sguyader: /* Color and Light */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What kind of local control?==&lt;br /&gt;
&lt;br /&gt;
Several types of local control exist in mainstream applications :&lt;br /&gt;
# “lasso”, associated with layers and fusion masks (e.g. Photoshop©). This kind of control is widespread (Photoshop, Gimp, Darktable…) and users tend to favor those, at the expense of the type described in 3. below, which is less well known;&lt;br /&gt;
# dedicated tools for the removal of image defects such as “red eyes”, or “spots” associated with sensor imperfections or dirt;&lt;br /&gt;
# “U-points” controls, used until recently in Nikon Capture NX2©, or as an add-on to other software such as Nik Software©. For those (rare now) who tried such programs, there’s no way turning back to layers and fusion masks! This type of local control requires learning something different, and a cognitive “reprogramming”. In my opinion, this kind of local control is globally more efficient.&lt;br /&gt;
&lt;br /&gt;
The algorithm developed in the current version of RawTherapee is close in its principle to the U-points described above. Of course, the code used in Nik Software is not disclosed, but several years ago I was attracted by the simplicity of use and the efficiency of U-points, and I started developing a product which would use neither lassos, nor layers or fusion masks. Of course, nothing prevents us from having all 3 types of local control in the same program.&lt;br /&gt;
&lt;br /&gt;
The current version of the filter is perfectible, particularly regarding the user interface (GUI):&lt;br /&gt;
* for managing and viewing the RT-spots (control spots) on screen,&lt;br /&gt;
* for manipulating the different sliders, which would ideally be better if integrated to the actual control points, as done in Nik Software.&lt;br /&gt;
&lt;br /&gt;
However, those two aspects don’t harm everyday use, nor code portability.&lt;br /&gt;
&lt;br /&gt;
In order to improve manipulation and avoid long menus on screen, I added a GUI interface which is similar to the one used in the Wavelet tab, with “expanders”. Thus for each module (“Color and Light”, “Blur”, “Retinex”, …) you can choose to:&lt;br /&gt;
# display (or not) the full list of commands: sliders methods, curves…&lt;br /&gt;
# activate (or not) all the functions of the module.&lt;br /&gt;
&lt;br /&gt;
Warning: The second choice activates or cancels all the RT-spots. (It would be possible in theory to add this capability to every single RT-spot, but for what purpose?)&lt;br /&gt;
&lt;br /&gt;
===Lab and RGB local controls===&lt;br /&gt;
* The first algorithms are coded in L*a*b* mode with the following modules: “Color and Light”, “Blur / Add noise”, “Retinex”, “Tone mapping”, “Sharpen”, “Contrast by Detail Levels”, “Denoise”. Two additional modules have been added: “Exposure” and “Vibrance”.&lt;br /&gt;
* See below for the principles of the different algorithms, but one key point to remember for shape detection and artifact limitation, is that the Lab mode preserves the “hue” tint, which is crucial.&lt;br /&gt;
* The idea of an “RGB” module comes to one’s mind, with ''a minima'':&lt;br /&gt;
** a “White balance” module, which would allow to locally adjust the white balance, for example to warm up shadows, or to deal with mixed scene lighting such as “daylight” and “tungsten”. This module needs to be inserted just after “demosaic”.&lt;br /&gt;
&lt;br /&gt;
====Auto White balance====&lt;br /&gt;
The “White balance” module (in the “autowblocal” branch) serves two purposes:&lt;br /&gt;
* allowing a local adjustment of the white balance (of course)&lt;br /&gt;
* testing new algorithms for automatic white balance adjustment:&lt;br /&gt;
** in general use (full image), in order to achieve better results than with the current algorithm. Of course one will tell me that I should create a specific branch for “White balance”, but here I’m trying to hit two targets with one bullet.&lt;br /&gt;
&lt;br /&gt;
As a reminder, I’ve been asked in 2012 and 2013 to develop an iterative white balance “Auto Robust WB[http://ieeexplore.ieee.org/document/1649677/]”. At that time, another developer and I had spent a lot of time on this for an unsatisfactory result, so we gave up. Since then, benefiting from this experience, I resumed this work but in the reverse way! Now, if I’m correct, the algorithm works. I took advantage of this new capability (currently working on raw images only) to search in the academic literature for other auto WB algorithms. I found, and developed two new algorithms:&lt;br /&gt;
* “auto edge”[https://www.researchgate.net/publication/301419990_A_Method_to_Improve_Robustness_of_the_Gray_World_Algorithm]: the idea is to create an accentuation mask allowing to reinforce parts of the image where details are more prevalent, compared to flatter regions.&lt;br /&gt;
* “auto standard deviation”[http://www.acad.bg/rismim/itc/sub/archiv/Paper3_1_2012.pdf]: here, the image (or part of it for the local control) is divided in 12 zones, for each of which mean and standard deviation are computed, and the result assembled.&lt;br /&gt;
A third algorithm, “Color by correlation”[https://courses.cs.washington.edu/courses/cse467/08au/labs/l5/whiteBalance.pdf], looks promising but I’m facing several difficulties. After many trials of many types, the results are just too erratic…&lt;br /&gt;
&lt;br /&gt;
I also added the notion of gamma:&lt;br /&gt;
* the same principles which deal with luminance distribution – gamma sRGB – used in the main RawTherapee code.&lt;br /&gt;
&lt;br /&gt;
Bear in mind that the automatic white balancing is a totally non deterministic mathematical problem. The algorithms may perform more or less well (and faster or slower), but a perfect result can’t exist! Why is it so? If one is referring to the principles of color management ([http://rawpedia.rawtherapee.com/Color_Management_addon/fr#Balance_des_blancs]), it is necessary to have knowledge of the three of: the coloured object, the illuminant and the observer. At least two of those are unknown in practice. In addition, the environment in which an image is shot is not known while it has an effect on the perception (CIECAM), and the same is true during both image editing and viewing. The mission is thus almost impossible!&lt;br /&gt;
&lt;br /&gt;
The aim of the “White balance” module is '''for testing the algorithms''', there are 7 of them at least, and twice that number if “gamma sRGB” is considered. Indeed, in order to circumvent the obstacles encountered five years ago, instead of the using the image before demosaicing, I used the image just after demosaicing, allowing to apply (or not) “gamma sRGB”, ending in the same conditions as in normal use (but without normal “White balance” and “ICC or DCP” profile).&lt;br /&gt;
&lt;br /&gt;
Ideally, we should test the algorithms on many images, as well: which algorithm(s) to keep and implement in normal – global RGB – mode (maybe one or two, in addition to the current algorithm which we should keep for compatibility).&lt;br /&gt;
&lt;br /&gt;
====Local control of White balance====&lt;br /&gt;
The local control is currently limited to 1 spot only, but there’s no difficulty to increase this if users want so… while waiting for the evolution of “locallab”.&lt;br /&gt;
&lt;br /&gt;
Of course, I hear voices say “it doesn’t work”, or “the output doesn’t match with the preview”. But it does work! And it is more than evident that matching exactly the preview is by definition almost impossible… (differences between shadows, sun light, different illuminants, etc…) whatever the relevance of the algorithm.&lt;br /&gt;
&lt;br /&gt;
==What are the challenges we need to solve?==&lt;br /&gt;
Several general issues need to be solved so as to achieve smoothness in use:&lt;br /&gt;
* allow an (almost) unlimited number of RT-spots (the name we chose for the control spots in RawTherapee);&lt;br /&gt;
* adapt the local algorithms to be aware of scale, because many of them take the image size – the treated area – into account. This aspect is fundamental, particularly with curves which act on the whole image;&lt;br /&gt;
* minimise memory use and computation time for JPG and TIFF output;&lt;br /&gt;
* allow easy updates in case of evolution of either the algorithms or the number of methods/modules;&lt;br /&gt;
* optimise (minimise) the differences between the preview and the output.&lt;br /&gt;
* etc…&lt;br /&gt;
&lt;br /&gt;
For each RT-spot:&lt;br /&gt;
* allow for the action to occur, on user choice, either inside or outside (“Inverse” mode) of the selection area;&lt;br /&gt;
* allow shape detection, on user choice, in order to limit the action based on features/shapes;&lt;br /&gt;
* take care of the transition between the center of the treated area and the other parts of the image;&lt;br /&gt;
* etc…&lt;br /&gt;
&lt;br /&gt;
Currently, RT-spots are operational in Lab mode with the following modules and methods:&lt;br /&gt;
# “Colour and Light”: “Lightness”, “Chrominance”, “Contrast” in normal mode with 4 curves L=f(L), L=f(H), C=f(C), H=f(H), and in “inverse” mode;&lt;br /&gt;
# “Exposure”: normal mode only;&lt;br /&gt;
# “Vibrance:” normal mode only;&lt;br /&gt;
# “Blur &amp;amp; noise”: normal and “inverse” modes;&lt;br /&gt;
# “Retinex”: normal and “inverse” modes, now also with “transmission gain” curve;&lt;br /&gt;
# “Sharpening”: normal and “inverse” modes;&lt;br /&gt;
# “Contrast by detail levels” (CBDL): normal mode only;&lt;br /&gt;
# “Denoise”: normal mode only.&lt;br /&gt;
&lt;br /&gt;
==General principles==&lt;br /&gt;
===The RT-spot object===&lt;br /&gt;
As I mentioned earlier, the system used in RT is similar to the one developed in Nik Software, but with some significant differences:&lt;br /&gt;
* each RT-spot can be viewed as an object with a number of fields (about 70 as of today), made of sliders, curves, control points, etc…;&lt;br /&gt;
* each field, grouped in modules, can be activated or not, and have different parameter values according to their nature;&lt;br /&gt;
* the modules are made to be coherent for the user: “Color and Light”, “Exposure”, “Contrast”, “Vibrance”, “Blur”, “Retinex”, “Sharpening”, “Tone Mapping”, “Contrast by detail levels”, “Denoise”;&lt;br /&gt;
* the number of RT-spot objects can vary from 2 up to 500;&lt;br /&gt;
* data describing the RT-spot objects are stored in text files with .mip extension;&lt;br /&gt;
* creating, modifying and tracking of the RT-spot objects are done in a “for” loop;&lt;br /&gt;
* there’s no code duplication.&lt;br /&gt;
&lt;br /&gt;
===Partitioning into 4 zones – previewing the RT-spot area===&lt;br /&gt;
When the user selects an RT-spot, the screen preview shows:&lt;br /&gt;
* a centre, made of a circle whose diameter and position can be adjusted directly using the mouse or the sliders;&lt;br /&gt;
* two horizontal and two vertical handles, whose position can be modified directly using the mouse or the provided sliders, controlling the extent of the area affected by the RT-spot;&lt;br /&gt;
* if &amp;quot;Show spot delimiters&amp;quot; is checked in &amp;quot;Preferences&amp;quot; &amp;gt; &amp;quot;General&amp;quot; tab &amp;gt; &amp;quot;Local adjustments&amp;quot;, one can visualise approximately the area affected by the spot. Because I couldn’t work cleanly with the « arc/ellipse/scale » function in the Cairo graphics library, I made each quadrant defined by a pseudo-ellipse made of 3 Bézier curves joining each other. In most cases the approximation is satisfying… To help grabbing the 4 handles, I made them longer (the Bézier curves are inactive!).&lt;br /&gt;
&lt;br /&gt;
We obtain 4 zones, whose orientation cannot be modified (the default rotation angle is set to zero). Those 4 zones have each of their vertices connected by imaginary ellipses.&lt;br /&gt;
&lt;br /&gt;
It is possible to drag the handles outside the image preview area.&lt;br /&gt;
&lt;br /&gt;
It should be possible to replace the ellipse with a hand drawn curve (even if I think its usefulness is debatable because of the existence of the shape detection algorithm), as long as the homothetic transform of the curve doesn’t intersect with the original curve. Although the benefits from this intellectually satisfying “improvement” should negligible in the case of the RT-spots, it will be possible to make the current RT-spots and lasso type of controls coexist eventually.&lt;br /&gt;
&lt;br /&gt;
===The &amp;quot;normal&amp;quot; and &amp;quot;excluding&amp;quot; types of RT-spots===&lt;br /&gt;
Two types of RT-spots are available:&lt;br /&gt;
* &amp;quot;Normal&amp;quot;: these are the spots which do the local retouching. Each new RT-spot takes into account the effect of existing spots when their zone of influence overlap (a sort of recursive action).&lt;br /&gt;
* &amp;quot;Excluding&amp;quot;: adding a new &amp;quot;excluding&amp;quot; RT-spot allows to revert the effect created by a &amp;quot;normal&amp;quot; RT-spot in their overlapping zone of influence , from the original image data (but doing its calculations from the reference values of the area affected by the &amp;quot;normal&amp;quot; RT-spot).&lt;br /&gt;
&lt;br /&gt;
For both types, the user has access to most of the modules (&amp;quot;Color and Light&amp;quot;, &amp;quot;Contrast by detail levels&amp;quot;, &amp;quot;Blur&amp;quot;, ...)&lt;br /&gt;
&lt;br /&gt;
====Comments about the &amp;quot;excluding&amp;quot; RT-spot====&lt;br /&gt;
* The principle of the &amp;quot;excluding&amp;quot; spot is similar to the &amp;quot;counterpoint&amp;quot; in Capture NX2, and is useful when for example, the effect of a &amp;quot;normal&amp;quot; RT-spot bleeds into an area which the user wants to be unaffected. This unwanted effect happens when when the tints of the two areas (the area the user wants to be affected, and the area one wants to remain unaffected) are to close.&lt;br /&gt;
* The underlying algorithm is similar to the main algorithms used elsewhere in &amp;quot;locallab&amp;quot;, and is based on tint differences. While it's not perfect it should give satisfaction 70% of the time.&lt;br /&gt;
* I implemented an additional algorithm (with no guarantee that it will actually work one day) to help discriminate the areas, based on a Sobel-Canny transform. The transform is coded but is not yet accessible to the user, as I'm still working to make it more efficient.&lt;br /&gt;
&lt;br /&gt;
====How to use the &amp;quot;excluding&amp;quot; RT-spot, and its limitations====&lt;br /&gt;
# Create a new RT-spot over the area you want to restore.&lt;br /&gt;
# In the &amp;quot;Settings&amp;quot; panel, from the &amp;quot;Spot method&amp;quot; combobox choose &amp;quot;Excluding spot&amp;quot;.&lt;br /&gt;
# Adjust &amp;quot;Scope&amp;quot;, &amp;quot;Transition&amp;quot; and &amp;quot;Spot size&amp;quot; as well as the shape of the zone of influence using the 4 handles, until you get the desired reversion of the effect. You can use complimentary adjustments such as &amp;quot;Color and light&amp;quot;, etc.&lt;br /&gt;
The algorithm computes the reference values (tint, chroma, luma) from the the current image (see below). As a consequence, the &amp;quot;excluding&amp;quot; effect won't work if the image area is black (for example when the user uses a normal RT-spot using &amp;quot;Color and light&amp;quot; in inverse mode to create a black frame).&lt;br /&gt;
Sometimes, when the &amp;quot;inverse&amp;quot; mode is selected, the &amp;quot;excluding&amp;quot; spot algorithm may not work as expected and lead to a difference between the preview and the output (JPG, TIFF) image. Increasing the value of &amp;quot;Scope&amp;quot; of the &amp;quot;excluding&amp;quot; RT-spot should help in this situation.&lt;br /&gt;
&lt;br /&gt;
===Tint, chroma, luminance references and the algorithm principle in “normal” mode===&lt;br /&gt;
In order to develop an efficient shape detection algorithm:&lt;br /&gt;
* The central circle zone is used as the reference. Based on the diameter value chosen by the user, the algorithm computes the tint (hue), chroma and luminance averages.&lt;br /&gt;
* The choice of the central zone diameter depends on the use intent. For example, if working on a foliage area the user would benefit from choosing a smaller diameter value in order to select only the foliage green; in contrast, for skin tones the user should increase the diameter to avoid the detection of parasites (noise, eye lashes…).&lt;br /&gt;
* For each quadrant, depending on the the value of the “Scope” slider, the algorithm does:&lt;br /&gt;
# take into account the tint difference between the zone centre and the affected pixel;&lt;br /&gt;
# through a complex algorithm based on the deltaE notion (perceived difference between two colours, taking tint, chroma and luminance into account), decrease the amount of applied effect as a function of the difference between the central zone and the affected pixel;&lt;br /&gt;
# follow either a linear or a parabolic law to adjust the amount of applied effect, based on the specific the case.&lt;br /&gt;
&lt;br /&gt;
This allows adapting the amount of effect according to the above-mentioned criteria. For example, if the central circle is located on foliage, the action will be limited to the leaves, without touching the background (which would be impossible to obtain with the lasso type of controls). Additionally, if some other foliage resides within the area covered by the RT-spot, it will also be affected.&lt;br /&gt;
* Adjusting the value of the “Transition” slider modifies the transition of the effect (from the centre to the edge): on 50, the inner (linear) half will get the full 100% action/effect, while the effect in the outer half will gradually transition from 100% to 0% towards the edge;&lt;br /&gt;
* By increasing the value of “Scope”, progressively more of the selected area is taken into account, whatever the tint, chroma and luminance;&lt;br /&gt;
* Conversely, by decreasing the “Scope” value the effect will get limited to the pixels which are more similar (in terms of deltaE) to the reference zone.&lt;br /&gt;
&lt;br /&gt;
The shape detection algorithm works in “Normal” mode except for some modules (“Denoise”). It’s not implemented in “Inverse” mode, doing so would not make sense.&lt;br /&gt;
&lt;br /&gt;
The algorithm will see its performance increase when the user chooses “Enhanced” or “Enhanced + chroma denoise” in the “Global quality:” combobox. The second choice additionally applies a low amount of chroma noise reduction in order to get rid of artefacts which could be brought up by the “Enhanced” algorithm (note that the chroma denoise step increases memory use and computing time).&lt;br /&gt;
&lt;br /&gt;
The algorithm is used in full capacity for “scope” &amp;lt; 20.&lt;br /&gt;
&lt;br /&gt;
===Why no alternative algorithms?===&lt;br /&gt;
It should be possible to implement other shape detection algorithms than the deltaE-based one used currently, for example:&lt;br /&gt;
* edge detection algorithms such as “Canny” or “Sobel”;&lt;br /&gt;
* wavelet decomposition.&lt;br /&gt;
&lt;br /&gt;
But in both cases, everything would have to be done!&lt;br /&gt;
&lt;br /&gt;
===Functioning in “inverse” mode===&lt;br /&gt;
When it is available, the “Inverse” mode is extremely simplified: only the “Transition” slider can be used to apply the effect.&lt;br /&gt;
As of late October 2017, I devised a new method for “Inverse” mode. It is limited to the “Blur &amp;amp; Noise” module (see the corresponding section below).&lt;br /&gt;
&lt;br /&gt;
===Maximum number of RT-spots===&lt;br /&gt;
By default the number of available RT-spots is 8. You can choose any number between 2 and 499. For this you only need to change the parameter “Nspot” in the “options” file (for example: Nspot=12). Restart RawTherapee for the modification to be taken into account.&lt;br /&gt;
&lt;br /&gt;
===The “super” algorithm===&lt;br /&gt;
The key to “success” was the algorithm implemented in late January 2017, which works this way:&lt;br /&gt;
# on the pixel data which are within the area covered by the RT-spot, the algorithm applies either a “traditional” curve, a slider, or a normal transfer function (“Retinex”, “Tone Mapping”, “Contrast by detail levels”, “Vibrance”, …);&lt;br /&gt;
# the LUT or the transfer function is converted into an equivalent of a slider, separating negative and positive values so that the function can be viewed as multiple sliders (as many sliders as there are pixels) in the -100, 0, +100 interval;&lt;br /&gt;
# the data are passed to the shape detection function – the 4 quadrants. For every pixel, the difference in terms of tint, chroma and luma is computed with regards to the central reference. The linear variation equations are estimated for luminance (L=f(L)), chroma (C=f(C)) or transfer functions;&lt;br /&gt;
# different corrections are applied to account for the environment (sky, skin tones…)&lt;br /&gt;
# a correction is made (with threshold and iterations) in order to avoid correcting (or only slightly, based on the user’s choice) the grey or neutral tones which are in the same tint as the reference (but with a low chroma value);&lt;br /&gt;
# the parameters are weighted based on the shape of the RT-spot (ellipses) and the transition zone;&lt;br /&gt;
# the values of the “Global quality:” parameters are important, particularly so for images with a low amount of noise – chroma noise is interpreted by the algorithm being of the same colour as the spot. It is thus necessary to suppress this noise, that is the purpose of “Enhanced + chroma denoise” (this algorithm may not be sufficient, though – in this case using the local “Denoise” module may be useful).&lt;br /&gt;
&lt;br /&gt;
This new (“super”) algorithm seems to perform generally well, but in the event when the RT-spot is located in a grey/neutral or flat area, the algorithm may fail. In such cases, using the old algorithm is recommended (except for “Retinex”, “Tone Mapping” and “Contrast by detail levels” for which it is made unavailable for the sake of code simplicity).&lt;br /&gt;
&lt;br /&gt;
===Artefact reduction and the “Global quality” algorithms===&lt;br /&gt;
By default, “Global quality:” is set to “Enhanced + chroma denoise”. Whereas it increases computation time, it is still generally preferable. In case one wants a more responsive preview, “Enhance” or “Standard” can be chosen (good for exploring the image).&lt;br /&gt;
* two sliders allow reducing artefacts and improving the algorithm’s rendering. They work based on chroma, in neutral/gray tones. To completely remove its effect, one can simply set “iterations=0”. These sliders may be used for &amp;quot;Color light&amp;quot;, &amp;quot;Exposure&amp;quot;, &amp;quot;Retinex&amp;quot;, &amp;quot;Vibrance&amp;quot;, &amp;quot;Tone mapping&amp;quot; and &amp;quot;Contrast by detail levels&amp;quot;;&lt;br /&gt;
* for (even slightly) noisy images, the algorithms may be misled. In this case it is recommended to keep &amp;quot;Global quality:”  set to “Enhanced + chroma denoise&amp;quot;, and (sometimes) activate the local “Denoise” module and adjust the sliders very gently (including “Luminance”);&lt;br /&gt;
* under some circumstances, with “Tone Mapping” for example, the artefact reduction algorithm may actually generate more artefacts. When it happens, set “iterations=0”.&lt;br /&gt;
&lt;br /&gt;
If your images are generally clean (no or very low noise), you can choose to have “Standard” as the default for “Global quality:” – this will speed up the image processing. To do so, go to “Preferences” &amp;gt; “Performance and quality” tab &amp;gt; “Local adjustments” and choose the “Standard” algorithm among the 3 options. This will become the new default  when new RT-spots are created, but of course the algorithm can still be changed on the fly by choosing from the “Global quality” combo box.&lt;br /&gt;
&lt;br /&gt;
===Avoid color shift===&lt;br /&gt;
The “Avoid color shift” checkbox serves two purposes:&lt;br /&gt;
* put the colours within the current working profile gamut, using a relative colorimetry;&lt;br /&gt;
* adjust colours using a “Munsell” correction – particularly for red-orange and blue-purple colours, when saturation in the L*a*b* space has changed significantly.&lt;br /&gt;
&lt;br /&gt;
===“mip” files – Principles of the multi-point algorithm===&lt;br /&gt;
For the local control system to work and keep track of RT-spot objects, a text file – similar to a pp3 – is written in 2 possible places:&lt;br /&gt;
* next to the edited image file. If, for example, you edit an image named ASC4509.NEF, a new file named ASC4509.NEF.mip will be generated in the same folder. In this case, several sessions can be open for the same image, as long as copies of the image are stored in different folders. However, the folder names in the path have to contain ASCII characters only, otherwise it will make the program crash;&lt;br /&gt;
* in the dedicated “mip” folder, within the “cache” directory (through an MD5 hash number which identifies the file). This is the default. If chosen, when multiple copies of the same file exist in distinct folders, editing them creates as many “mip” files. This option allows the use of non ASCII characters in the folder names and path.&lt;br /&gt;
&lt;br /&gt;
The choice between these two behaviours is made in “Preferences” &amp;gt; “Image processing” tab &amp;gt; “Mip profiles”.&lt;br /&gt;
&lt;br /&gt;
The “mip” files contain the data which are passed to RawTherapee through processes of the “procparams” type, and LUTs which allow editing in zoom mode. When updating RawTherapee to a new version, it may be required to delete the “mip” files (or the whole cache) to avoid a potential crash of the application. This can be achieved by going to “Preferences” &amp;gt; “File browser” tab, then choosing “Clear mip” and/or “Clear pp3” – all this is valid only if “mip” and “pp3” files have been set to be saved to the cache folder, otherwise they will have to be manually deleted from the working folder. Keeping older “mip” and “pp3” files may lead to instability or crashes of the application.&lt;br /&gt;
&lt;br /&gt;
====Architecture of the filter====&lt;br /&gt;
When I “ventured” into a multi-point, no-layer and no-mask system, code duplication had to be avoided. Indeed, it is unthinkable to consider, for 10 RT-spots, generating 10 GUI code blocks, and just as many code blocks in “rtengine”. After careful consideration, the idea was to have a file updating and tracking in real time – i.e. a file which would follow each modification made by the user – the actions/modifications history.&lt;br /&gt;
&lt;br /&gt;
Of course, the parameters used by RawTherapee for the GUI and for the main code through “params” are of different types:&lt;br /&gt;
* numeric: integer, float, double,…&lt;br /&gt;
* Boolean&lt;br /&gt;
* string (in choice menus for the different modules)&lt;br /&gt;
* curves, through “vectors” of type double with dynamic dimension&lt;br /&gt;
* …&lt;br /&gt;
&lt;br /&gt;
====Data conversion====&lt;br /&gt;
In order to simplify data management, the first step is to convert all data to integers. Sometimes this can lead to a slight precision loss, which I think is negligible.&lt;br /&gt;
* This operation is very simple for numeric values, even though in some cases (such as hue, which is expressed in radian in the interval [-Pi, +Pi]) it needs a double “float*100 and /100 conversion to keep precision.&lt;br /&gt;
* It is logical for Boolean operations and methods.&lt;br /&gt;
* However, it is a complex matter regarding curves. The values to be recorded in the “mip” file are of type vector&amp;lt;double&amp;gt;, in a dynamic table of numeric values. There may be a simpler way, by using existing functions from “procparams”, but I didn’t succeed. &lt;br /&gt;
Nevertheless, I could get around this by:&lt;br /&gt;
# converting doubles to integers with 3 significant figures – which is largely enough,&lt;br /&gt;
# then converting the “vector” to a variable length character string,&lt;br /&gt;
# the writing and reading of this character string and converting to a vector dynamically using an appropriate function (”strcurv_data”). Note that this function allows adjusting the curves within the limit of 16 inflection points (Bézier curve) for the flat curve, and 32 points for the diagonal, which should be enough. Whether this would not be enough, it should be possible to increase that number, though compatibility would be compromised.&lt;br /&gt;
&lt;br /&gt;
====Some elements about curves====&lt;br /&gt;
The implementation of curves has been a complex task, particularly since:&lt;br /&gt;
# each curve needs its own reset function – resize() at each iteration,&lt;br /&gt;
# which implies oddities regarding their description, for example the diagonal curve gets initialised with several points, despite it looks being “empty”. This is mandatory for correct functioning, but this means that the curve is always open/active. Consequently, to avoid some unwanted loss of computation time in “preview” mode, the user has to activate the curve by clicking on the “curves” combobox. The same activation is necessary for L=f(H) and C=f(C) curves. While clicking enabling the “curves” (linear) would seem to be a better solution, it didn’t work despite many trials.&lt;br /&gt;
# during all the procedure, we need to set each &amp;quot;params&amp;quot; value to &amp;quot;clear&amp;quot; for curves, for each LUT, at each iteration and then through a &amp;quot;vector&amp;quot; to reassign the good, updated values to &amp;quot;curve params&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
====Data storing and dynamic use====&lt;br /&gt;
Once data have been converted:&lt;br /&gt;
* they are stored in a text (mip) file,&lt;br /&gt;
* each one is referenced inside a 2-dimension dynamical table:&lt;br /&gt;
# dataspot[x][y] for numeric and boolean values and methods, where “x” is the representative index of the parameter (e.g. “9” is for “lightness”) and “y” represents the current RT-spot (control spot). Value “0” represents the current in-use value (the one stores in “params”).&lt;br /&gt;
# retistr[y], llstr[y], lhstr[y], ccstr[y], hhstr[y], skinstr[y], pthstr[y], exstr[y] for parameters of type “curve”. Currently there are only 8 parameters, used for local “Retinex”, “Color and light” (L=f(L), C=f(C), L=f(H), H=F(H)), “Vibrance” and “Exposure”, but it is easy to add more. “y” is used as above in 1.&lt;br /&gt;
&lt;br /&gt;
The way data are stored and used fits well with improccoordinator.cc (current management / preview) and simpleprocess.cc (TIFF / JPG  output) files, but not so with dcrop.cc and the partial display of the image (RawTherapee’s pipeline).&lt;br /&gt;
&lt;br /&gt;
In this case (zoom / preview) another solution had to be found in order to synchronise the modifications in real time. I made use of LUTs, so that to each entry referenced in the table described above a LUTi(z) is associated, with z=500 possible entries (500 corresponds to the current maximum number of RT-spots, but this limit can be decreased or increased). The LUTi “z” corresponds to the dataspot “y”. A 25,000 entries LUTi (arbitrary number) is used for “retistr”, “llstr”, “lhstr”, “ccstr”, “hhstr”, “skinstr”, “pthstr”, “exstr” for storing each “vector” curve value in memory (up to 69 values stored as integers).&lt;br /&gt;
&lt;br /&gt;
During data processing, exchanges occur between: params, dynamic tables and LUTi. The values used by dcrop.cc are dynamically linked to dynamical tables by parent→.&lt;br /&gt;
&lt;br /&gt;
====Exchange processes and dynamic data storing====&lt;br /&gt;
# reading of the “mip” file to check the version number and guide the updates&lt;br /&gt;
# creating the “mip” file if it doesn’t exist&lt;br /&gt;
# storing the data in LUTi and dynamic tables from the values stored in “params” (index 0 values)&lt;br /&gt;
# first interactive update with the GUI through a transfer function between “rtengine” and locallab.cc (aloListener → localretChanged). This is one of the 3 functions required for the process to work correctly&lt;br /&gt;
# reading of the “mip” file and data storing in dynamic tables (index values ==&amp;gt; y) according to the number of RT-spots&lt;br /&gt;
# creating a loop – according to the number of RT-spots – which updates LUTi (required by “dcrop”) and “params” values from values stored in the dynamic tables&lt;br /&gt;
# call to the “Lab_local” function which contains the algorithms controlling each RT-spot (luminance, sharpness, retinex, denoise, …)&lt;br /&gt;
# second interactive update with the GUI through another transfer function between “rtengine” and “locallab.cc”&lt;br /&gt;
# treatment of the current RT-spot by using the index (0) values from the dynamic tables. These values are attributed to 1) “params”, 2) LUTi and 3) current index values&lt;br /&gt;
# call to the “Lab_local” function for the current RT-spots&lt;br /&gt;
# saving to the “mip” file.&lt;br /&gt;
&lt;br /&gt;
Note that if the user modifies the curve (amplitude, number of inflection points) a third interactive update is made in order to conform all of the data according to events.&lt;br /&gt;
&lt;br /&gt;
====A few unavoidable “fantasies”====&lt;br /&gt;
Of course everything looks simple, the process works if, and only if, all the data are dynamically updated. I’ve tried a lot, went groping, and finally found a working solution… but an uncanny one. There’s probably a more “informatically” correct way to do it, but at this point I’ve done as explained above and hereafter.&lt;br /&gt;
&lt;br /&gt;
The 3 exchanges between “rtengine” and the GUI occur with 3 parameters which actually do nothing in the program except doing the update process:&lt;br /&gt;
# “anbspot” which takes values of 0 or 1&lt;br /&gt;
# “cTgainshaperab” (curve) which takes any value bewteen 0.70 and 0.90&lt;br /&gt;
# “retrab” which varies around 500.&lt;br /&gt;
I have added 3 more parameters (in the form of sliders) – hueref, chromaref and lumaref – hidden from the user but which are used to update the system in real time, to correctly take into account the reference “spot” values. Allowing those 3 parameters to vary brings stability and allows real time updates. Increasing the number of those “fantasy” parameters should not be necessary. These extra parameters are hidden to the user, and are only visible in the history.&lt;br /&gt;
&lt;br /&gt;
In addition, I had to add some empirical time delays, giving time to time… Time delay is used for example when the user modifies the curve (amplitude, number of inflection points).&lt;br /&gt;
&lt;br /&gt;
==Specificity of the local mode (as compared to “Lab adjustments”)==&lt;br /&gt;
Hereafter is some useful information for the user, often specific to the local mode.&lt;br /&gt;
&lt;br /&gt;
===Color and Light===&lt;br /&gt;
* The algorithms used for luminance and contrast in local mode differ from the ones used in “Lab adjustments”, which may lead to differences in rendering.&lt;br /&gt;
* The luminance algorithm is made such that below -90 and down to -100 for “Lightness”, it is possible to increase the image's “darkness”, almost to the point of getting a luminance value close to 0. To accentuate this effect, “Chrominance” can be decreased and “Scope” increased.&lt;br /&gt;
* The inverse mode can be used for creating graduated frames. If “Ligthness” is set to -100 and &amp;quot;Chrominance&amp;quot; is reduced, the “frame border” will be black.&lt;br /&gt;
* For the “Lightness” and “Contrast” sliders, the user can choose among 2 algorithms: the first one (default) is close to that in “Lab adjustments” while the second one, activated through “Lightness - Contrast ‘Super’” is close to the algorithm used for the L=f(L) “Super” curve.&lt;br /&gt;
* Do not hesitate, when needed, to activate “Enhanced” or “Enhanced + chroma denoise” in the “Global Quality:” combobox.&lt;br /&gt;
&lt;br /&gt;
====Curves====&lt;br /&gt;
* An L=f(L) or C=f(C) curves allow controlling the luminance and chrominance for each RT-spot as a function of luminance or chrominance.&lt;br /&gt;
* An L=f(H) curve allows controlling the luminance for each RT-spot as a function of tint.&lt;br /&gt;
* An H=f(H) curve allows controlling the tint for each RT-spot as a function of tint.&lt;br /&gt;
The curves are activated by selecting one of the two algorithms from the “Curves types” combobox:&lt;br /&gt;
* “Normal”: the curves – particularly the one that is the most difficult to manage, L=f(L) – use an algorithm close to the one used with the sliders (Normal mode),&lt;br /&gt;
* “Super”: using a new algorithm, which I think performs very well (it even surprised me the first time I used it).&lt;br /&gt;
&lt;br /&gt;
Caution: when the RT-spot resides in an area which is neutral, grey or very uniform, the artefacts introduced by the new algorithm (“Super” algorithm for the curve or the slider) may be impossible to get rid of. Use one of the 2 older algorithms to avoid that.&lt;br /&gt;
&lt;br /&gt;
===Exposure===&lt;br /&gt;
The “Exposure” module may look like the the one in global RGB mode, but:&lt;br /&gt;
* it works entirely in L*a*b* mode, hence the differences in rendering;&lt;br /&gt;
* there’s no “Lightness”, “Chroma” or “Contrast” slider, whose functions are already fulfilled in the “Color and Light” module;&lt;br /&gt;
* there’s only one “Contrast” curve, similar to the L=f(L) firm “Color and Light”. Of course its effect is different from “Tone curve” which works in RGB mode. If needed, two L=f(L) curves can be activated, one under “Color and Light” and the other under “Exposure”.&lt;br /&gt;
&lt;br /&gt;
===Vibrance===&lt;br /&gt;
This module is similar to the main one (from RawTherapee's &amp;quot;Exposure&amp;quot; tab).&lt;br /&gt;
&lt;br /&gt;
===Blur &amp;amp; Noise===&lt;br /&gt;
“Blur” is activated only when “Radius” =&amp;lt; 2.&lt;br /&gt;
By significantly lowering the default value of “Scope” and possibly checking “Blur luminance only”, it is possible to get a different amount of blur for the different tints.&lt;br /&gt;
Since October 2017, 3 methods are proposed:&lt;br /&gt;
* “Normal”: the shape detection algorithm has been improved, it is now closer to shape detection algorithm proposed in the other modules;&lt;br /&gt;
* “Inverse”: a simplified algorithm, which doesn’t make use of “Scope”. The inversion is coarse and doesn’t allow a fine separation between the affected and unaffected areas;&lt;br /&gt;
* “Symmetric”: this new algorithm uses the same processes as “Normal”, and adjusting “Scope” the user can target the process with more precision.&lt;br /&gt;
Caution: &lt;br /&gt;
* Using the “Inverse” mode will blur large portions of the image, which can not be corrected later on.&lt;br /&gt;
* The action of “Scope” may sometimes appear puzzling: for instance, in a portrait, the eyes (which of course differ from the skin) may be blurred if the value of “Scope” is too low.&lt;br /&gt;
&lt;br /&gt;
===Tone Mapping===&lt;br /&gt;
Caution when uniformly coloured areas (sky, grey/neutral zones) have a similar tint to the area on which the RT-spot is placed. In cases where this leads to artefacts, set the “Iterations” slider to 0 in “Settings” &amp;gt; “Reduce artefacts – Improve algorithm”.&lt;br /&gt;
&lt;br /&gt;
===Retinex===&lt;br /&gt;
Compared to the standard “Retinex” module, the local “Retinex module has simplified controls, and is applied at the end of the pipeline instead of the beginning. Since “mip” version 10002, the “Transmission gain” is specific to each RT-spot.&lt;br /&gt;
&lt;br /&gt;
===Sharpening===&lt;br /&gt;
Only the “RL Deconvolution” algorithm is provided here.&lt;br /&gt;
&lt;br /&gt;
===Contrast by detail levels===&lt;br /&gt;
Compared to the main RGB mode module, this one has:&lt;br /&gt;
* 5 levels instead of 6,&lt;br /&gt;
* no slider for “skin tone” protection (not needed since the algorithm works locally on the RT-spot area),&lt;br /&gt;
* an additional “Chroma” slider.&lt;br /&gt;
&lt;br /&gt;
Caution when uniformly coloured areas (sky, grey/neutral zones) have a similar tint to the area on which the RT-spot is placed. In cases where this leads to artefacts, set the “Iterations” slider to 0 in “Settings” &amp;gt; “Reduce artefacts – Improve algorithm”.&lt;br /&gt;
&lt;br /&gt;
===Denoise===&lt;br /&gt;
Compared to the main RGB mode module, this one has:&lt;br /&gt;
* only the wavelet tool working (no Fourier function, nor medians),&lt;br /&gt;
* less sliders and curves,&lt;br /&gt;
* the possibility to work differentially on fine or coarse noise for both luminance and chrominance noise.&lt;br /&gt;
&lt;br /&gt;
==A specific use case : reduction of image defects (dirty sensor, red eyes, …)==&lt;br /&gt;
“Locallab” had not been thought with the idea of correcting small image defects. However, some visible, “photographically disturbing” defects may actually be tamed or even removed. Of course, this is not incompatible with other more specialised modules which could be introduced (or not) into “Locallab”… At least 3 existing modules can serve this purpose, alone or in combination, by adapting their use:&lt;br /&gt;
* “Color and Light” for spot-like defects;&lt;br /&gt;
* “Contrast by detail levels” for spread out defects;&lt;br /&gt;
* “Blur and Noise” as an optional complement (caution, this is a destructive action, use moderately).&lt;br /&gt;
&lt;br /&gt;
These modules can be used either on the main image (raw, TIFF,  …) or on a flat-field image.&lt;br /&gt;
&lt;br /&gt;
===Using the “Color and Light” module===&lt;br /&gt;
* Activate “Color and Light”&lt;br /&gt;
* A red eye removal tool equivalent can be obtained by framing closely around the eye – central circle zone centered on the eye’s red, spot handles close to the eye – low “Scope” value, then lowering “Lightness” and “Chrominance” to -100.&lt;br /&gt;
* The same idea allows reducing the “IR spot” kind of defect by framing closely around the defect – central circle zone centred on the defect, spot handles close to the defect area – then lowering “Chrominance” to taste, and if needed lowering the “scope” value.&lt;br /&gt;
* In some (simple) situations, a “dirty sensor” defect can be reduced, in particular in the case of “sensor grease”. It can be seen as stains or spots on a uniform background. To attenuate this, choose a tight framing of around the defect – central circle on the centre of the defect (adapt the size of the RT-spot), drag the handles so that they are not too close to the border of the defect (this will make the transition less noticeable). Then: a) decrease “Transition” towards lower values; b) check “Lightness - Contrast “Super”; c) adjust “Lightness” and “Chrominance” as needed to bring the defect area closer to the unaffected area; d) if needed adjust slightly “Scope” to achieve the best result.&lt;br /&gt;
&lt;br /&gt;
===Using the “Contrast by detail levels” module===&lt;br /&gt;
When the sensor is dirty (grease), and when the affected area is large or if there are multiple small defects, “Contrast by detail levels” may be used, working as a sort of “wavelet” tool on luminance, and if needed on chrominance. In such cases: a) place the RT-spot on one of the stronger defects (adjust the size as needed); b) drag the handles so as to cover most of the affected area; c) set “Transition” to higher value; d) activate “Contrast by detail levels” and decrease the contrast of levels 3 and 4 (or lower); you can adjust the “Chroma” slider if needed.&lt;br /&gt;
&lt;br /&gt;
==Settings in the Preferences dialog==&lt;br /&gt;
Below is a list of the settings (already mentioned above in several places) which can be accessed from the “Preferences” dialog:&lt;br /&gt;
* In “Preferences” &amp;gt; “General” tab &amp;gt; “Local adjustments”, by checking the “Show spot delimiters” checkbox, an approximate zone delimitation is drawn which helps viewing the area affected by the RT-spot and its settings.&lt;br /&gt;
* If your images generally have low noise, you can set the default for “Global quality” to “Standard”, and get a significant speedup in processing time. This setting is found under “Preferences” &amp;gt; “Performance &amp;amp; Quality” tab &amp;gt; “Local adjustments”. The three choices for quality are selected from the “Local adjustments Quality method” combobox. Default is “Enhanced + chroma denoise”.&lt;br /&gt;
* Regarding “mip” files:&lt;br /&gt;
** the choice for “mip” files destination folder is set from “Preferences” &amp;gt; “Image processing” tab &amp;gt; “Mip Profiles”;&lt;br /&gt;
** in order to clean the generated “mip” profiles, go to “Preferences” &amp;gt; “File Browser” tab &amp;gt; “Cache Options” and click on the “Clear mip” button and/or “Clear pp3” – this is valid in the case where you chose to store “mip” files in the cache, otherwise if you chose to let RT write the “mip” files next to the input file, you will have to delete them manually. Note that the presence of older versions of “mip” and “pp3” files may lead to instability or even crashes of RawTherapee.&lt;br /&gt;
&lt;br /&gt;
==Processing time and memory use==&lt;br /&gt;
At image export time (output to JPG, TIFF…), for the “normal” mode, the algorithms compute the data only for in the RT-spot delimited areas, not for the whole image. Thus, processing time and memory stay reasonable. Note that of course, this will depend on the number of RT-spots, their size, and the type(s) of treatment done in these RT-spots.&lt;br /&gt;
&lt;br /&gt;
Excluding “Denoise” and “Sharpen”, processing time is in the order of a few tenths of a second per RT-spot, and memory use of a few hundred MB.&lt;br /&gt;
&lt;br /&gt;
Two settings have a strong influence on resource use:&lt;br /&gt;
    • “Denoise” which adds around 1 sec. of processing time, and 1 MB of memory use;&lt;br /&gt;
    • “Global quality: Enhanced + chroma denoise” which adds around 0.5 sec. And 0.6 MB.&lt;br /&gt;
These figures depend on the size of the RT-spot.&lt;br /&gt;
&lt;br /&gt;
==Future evolution==&lt;br /&gt;
Besides usual tweaking, bug corrections, improvements (settings, user interface)… it would be desirable to improve the GUI with regards to the creation/selection/modification of individual RT-spots.&lt;br /&gt;
&lt;br /&gt;
From a programming point of view, it should be possible to improve code readability and maintainability, and to integrate all the “mip” files code parts (as done in “rgbproc.cc”) which currently are linearly integrated to void procedures in “improccoordinator.cc”, “dcrop.cc” and “simpleprocess.cc”.&lt;/div&gt;</summary>
		<author><name>Sguyader</name></author>
	</entry>
	<entry>
		<id>http://rawpedia.rawtherapee.com/index.php?title=Local_Lab_Controls&amp;diff=3345</id>
		<title>Local Lab Controls</title>
		<link rel="alternate" type="text/html" href="http://rawpedia.rawtherapee.com/index.php?title=Local_Lab_Controls&amp;diff=3345"/>
		<updated>2017-11-10T20:35:52Z</updated>

		<summary type="html">&lt;p&gt;Sguyader: Add the information regarding the &amp;quot;excluding&amp;quot; RT-spot&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What kind of local control?==&lt;br /&gt;
&lt;br /&gt;
Several types of local control exist in mainstream applications :&lt;br /&gt;
# “lasso”, associated with layers and fusion masks (e.g. Photoshop©). This kind of control is widespread (Photoshop, Gimp, Darktable…) and users tend to favor those, at the expense of the type described in 3. below, which is less well known;&lt;br /&gt;
# dedicated tools for the removal of image defects such as “red eyes”, or “spots” associated with sensor imperfections or dirt;&lt;br /&gt;
# “U-points” controls, used until recently in Nikon Capture NX2©, or as an add-on to other software such as Nik Software©. For those (rare now) who tried such programs, there’s no way turning back to layers and fusion masks! This type of local control requires learning something different, and a cognitive “reprogramming”. In my opinion, this kind of local control is globally more efficient.&lt;br /&gt;
&lt;br /&gt;
The algorithm developed in the current version of RawTherapee is close in its principle to the U-points described above. Of course, the code used in Nik Software is not disclosed, but several years ago I was attracted by the simplicity of use and the efficiency of U-points, and I started developing a product which would use neither lassos, nor layers or fusion masks. Of course, nothing prevents us from having all 3 types of local control in the same program.&lt;br /&gt;
&lt;br /&gt;
The current version of the filter is perfectible, particularly regarding the user interface (GUI):&lt;br /&gt;
* for managing and viewing the RT-spots (control spots) on screen,&lt;br /&gt;
* for manipulating the different sliders, which would ideally be better if integrated to the actual control points, as done in Nik Software.&lt;br /&gt;
&lt;br /&gt;
However, those two aspects don’t harm everyday use, nor code portability.&lt;br /&gt;
&lt;br /&gt;
In order to improve manipulation and avoid long menus on screen, I added a GUI interface which is similar to the one used in the Wavelet tab, with “expanders”. Thus for each module (“Color and Light”, “Blur”, “Retinex”, …) you can choose to:&lt;br /&gt;
# display (or not) the full list of commands: sliders methods, curves…&lt;br /&gt;
# activate (or not) all the functions of the module.&lt;br /&gt;
&lt;br /&gt;
Warning: The second choice activates or cancels all the RT-spots. (It would be possible in theory to add this capability to every single RT-spot, but for what purpose?)&lt;br /&gt;
&lt;br /&gt;
===Lab and RGB local controls===&lt;br /&gt;
* The first algorithms are coded in L*a*b* mode with the following modules: “Color and Light”, “Blur / Add noise”, “Retinex”, “Tone mapping”, “Sharpen”, “Contrast by Detail Levels”, “Denoise”. Two additional modules have been added: “Exposure” and “Vibrance”.&lt;br /&gt;
* See below for the principles of the different algorithms, but one key point to remember for shape detection and artifact limitation, is that the Lab mode preserves the “hue” tint, which is crucial.&lt;br /&gt;
* The idea of an “RGB” module comes to one’s mind, with ''a minima'':&lt;br /&gt;
** a “White balance” module, which would allow to locally adjust the white balance, for example to warm up shadows, or to deal with mixed scene lighting such as “daylight” and “tungsten”. This module needs to be inserted just after “demosaic”.&lt;br /&gt;
&lt;br /&gt;
====Auto White balance====&lt;br /&gt;
The “White balance” module (in the “autowblocal” branch) serves two purposes:&lt;br /&gt;
* allowing a local adjustment of the white balance (of course)&lt;br /&gt;
* testing new algorithms for automatic white balance adjustment:&lt;br /&gt;
** in general use (full image), in order to achieve better results than with the current algorithm. Of course one will tell me that I should create a specific branch for “White balance”, but here I’m trying to hit two targets with one bullet.&lt;br /&gt;
&lt;br /&gt;
As a reminder, I’ve been asked in 2012 and 2013 to develop an iterative white balance “Auto Robust WB[http://ieeexplore.ieee.org/document/1649677/]”. At that time, another developer and I had spent a lot of time on this for an unsatisfactory result, so we gave up. Since then, benefiting from this experience, I resumed this work but in the reverse way! Now, if I’m correct, the algorithm works. I took advantage of this new capability (currently working on raw images only) to search in the academic literature for other auto WB algorithms. I found, and developed two new algorithms:&lt;br /&gt;
* “auto edge”[https://www.researchgate.net/publication/301419990_A_Method_to_Improve_Robustness_of_the_Gray_World_Algorithm]: the idea is to create an accentuation mask allowing to reinforce parts of the image where details are more prevalent, compared to flatter regions.&lt;br /&gt;
* “auto standard deviation”[http://www.acad.bg/rismim/itc/sub/archiv/Paper3_1_2012.pdf]: here, the image (or part of it for the local control) is divided in 12 zones, for each of which mean and standard deviation are computed, and the result assembled.&lt;br /&gt;
A third algorithm, “Color by correlation”[https://courses.cs.washington.edu/courses/cse467/08au/labs/l5/whiteBalance.pdf], looks promising but I’m facing several difficulties. After many trials of many types, the results are just too erratic…&lt;br /&gt;
&lt;br /&gt;
I also added the notion of gamma:&lt;br /&gt;
* the same principles which deal with luminance distribution – gamma sRGB – used in the main RawTherapee code.&lt;br /&gt;
&lt;br /&gt;
Bear in mind that the automatic white balancing is a totally non deterministic mathematical problem. The algorithms may perform more or less well (and faster or slower), but a perfect result can’t exist! Why is it so? If one is referring to the principles of color management ([http://rawpedia.rawtherapee.com/Color_Management_addon/fr#Balance_des_blancs]), it is necessary to have knowledge of the three of: the coloured object, the illuminant and the observer. At least two of those are unknown in practice. In addition, the environment in which an image is shot is not known while it has an effect on the perception (CIECAM), and the same is true during both image editing and viewing. The mission is thus almost impossible!&lt;br /&gt;
&lt;br /&gt;
The aim of the “White balance” module is '''for testing the algorithms''', there are 7 of them at least, and twice that number if “gamma sRGB” is considered. Indeed, in order to circumvent the obstacles encountered five years ago, instead of the using the image before demosaicing, I used the image just after demosaicing, allowing to apply (or not) “gamma sRGB”, ending in the same conditions as in normal use (but without normal “White balance” and “ICC or DCP” profile).&lt;br /&gt;
&lt;br /&gt;
Ideally, we should test the algorithms on many images, as well: which algorithm(s) to keep and implement in normal – global RGB – mode (maybe one or two, in addition to the current algorithm which we should keep for compatibility).&lt;br /&gt;
&lt;br /&gt;
====Local control of White balance====&lt;br /&gt;
The local control is currently limited to 1 spot only, but there’s no difficulty to increase this if users want so… while waiting for the evolution of “locallab”.&lt;br /&gt;
&lt;br /&gt;
Of course, I hear voices say “it doesn’t work”, or “the output doesn’t match with the preview”. But it does work! And it is more than evident that matching exactly the preview is by definition almost impossible… (differences between shadows, sun light, different illuminants, etc…) whatever the relevance of the algorithm.&lt;br /&gt;
&lt;br /&gt;
==What are the challenges we need to solve?==&lt;br /&gt;
Several general issues need to be solved so as to achieve smoothness in use:&lt;br /&gt;
* allow an (almost) unlimited number of RT-spots (the name we chose for the control spots in RawTherapee);&lt;br /&gt;
* adapt the local algorithms to be aware of scale, because many of them take the image size – the treated area – into account. This aspect is fundamental, particularly with curves which act on the whole image;&lt;br /&gt;
* minimise memory use and computation time for JPG and TIFF output;&lt;br /&gt;
* allow easy updates in case of evolution of either the algorithms or the number of methods/modules;&lt;br /&gt;
* optimise (minimise) the differences between the preview and the output.&lt;br /&gt;
* etc…&lt;br /&gt;
&lt;br /&gt;
For each RT-spot:&lt;br /&gt;
* allow for the action to occur, on user choice, either inside or outside (“Inverse” mode) of the selection area;&lt;br /&gt;
* allow shape detection, on user choice, in order to limit the action based on features/shapes;&lt;br /&gt;
* take care of the transition between the center of the treated area and the other parts of the image;&lt;br /&gt;
* etc…&lt;br /&gt;
&lt;br /&gt;
Currently, RT-spots are operational in Lab mode with the following modules and methods:&lt;br /&gt;
# “Colour and Light”: “Lightness”, “Chrominance”, “Contrast” in normal mode with 4 curves L=f(L), L=f(H), C=f(C), H=f(H), and in “inverse” mode;&lt;br /&gt;
# “Exposure”: normal mode only;&lt;br /&gt;
# “Vibrance:” normal mode only;&lt;br /&gt;
# “Blur &amp;amp; noise”: normal and “inverse” modes;&lt;br /&gt;
# “Retinex”: normal and “inverse” modes, now also with “transmission gain” curve;&lt;br /&gt;
# “Sharpening”: normal and “inverse” modes;&lt;br /&gt;
# “Contrast by detail levels” (CBDL): normal mode only;&lt;br /&gt;
# “Denoise”: normal mode only.&lt;br /&gt;
&lt;br /&gt;
==General principles==&lt;br /&gt;
===The RT-spot object===&lt;br /&gt;
As I mentioned earlier, the system used in RT is similar to the one developed in Nik Software, but with some significant differences:&lt;br /&gt;
* each RT-spot can be viewed as an object with a number of fields (about 70 as of today), made of sliders, curves, control points, etc…;&lt;br /&gt;
* each field, grouped in modules, can be activated or not, and have different parameter values according to their nature;&lt;br /&gt;
* the modules are made to be coherent for the user: “Color and Light”, “Exposure”, “Contrast”, “Vibrance”, “Blur”, “Retinex”, “Sharpening”, “Tone Mapping”, “Contrast by detail levels”, “Denoise”;&lt;br /&gt;
* the number of RT-spot objects can vary from 2 up to 500;&lt;br /&gt;
* data describing the RT-spot objects are stored in text files with .mip extension;&lt;br /&gt;
* creating, modifying and tracking of the RT-spot objects are done in a “for” loop;&lt;br /&gt;
* there’s no code duplication.&lt;br /&gt;
&lt;br /&gt;
===Partitioning into 4 zones – previewing the RT-spot area===&lt;br /&gt;
When the user selects an RT-spot, the screen preview shows:&lt;br /&gt;
* a centre, made of a circle whose diameter and position can be adjusted directly using the mouse or the sliders;&lt;br /&gt;
* two horizontal and two vertical handles, whose position can be modified directly using the mouse or the provided sliders, controlling the extent of the area affected by the RT-spot;&lt;br /&gt;
* if &amp;quot;Show spot delimiters&amp;quot; is checked in &amp;quot;Preferences&amp;quot; &amp;gt; &amp;quot;General&amp;quot; tab &amp;gt; &amp;quot;Local adjustments&amp;quot;, one can visualise approximately the area affected by the spot. Because I couldn’t work cleanly with the « arc/ellipse/scale » function in the Cairo graphics library, I made each quadrant defined by a pseudo-ellipse made of 3 Bézier curves joining each other. In most cases the approximation is satisfying… To help grabbing the 4 handles, I made them longer (the Bézier curves are inactive!).&lt;br /&gt;
&lt;br /&gt;
We obtain 4 zones, whose orientation cannot be modified (the default rotation angle is set to zero). Those 4 zones have each of their vertices connected by imaginary ellipses.&lt;br /&gt;
&lt;br /&gt;
It is possible to drag the handles outside the image preview area.&lt;br /&gt;
&lt;br /&gt;
It should be possible to replace the ellipse with a hand drawn curve (even if I think its usefulness is debatable because of the existence of the shape detection algorithm), as long as the homothetic transform of the curve doesn’t intersect with the original curve. Although the benefits from this intellectually satisfying “improvement” should negligible in the case of the RT-spots, it will be possible to make the current RT-spots and lasso type of controls coexist eventually.&lt;br /&gt;
&lt;br /&gt;
===The &amp;quot;normal&amp;quot; and &amp;quot;excluding&amp;quot; types of RT-spots===&lt;br /&gt;
Two types of RT-spots are available:&lt;br /&gt;
* &amp;quot;Normal&amp;quot;: these are the spots which do the local retouching. Each new RT-spot takes into account the effect of existing spots when their zone of influence overlap (a sort of recursive action).&lt;br /&gt;
* &amp;quot;Excluding&amp;quot;: adding a new &amp;quot;excluding&amp;quot; RT-spot allows to revert the effect created by a &amp;quot;normal&amp;quot; RT-spot in their overlapping zone of influence , from the original image data (but doing its calculations from the reference values of the area affected by the &amp;quot;normal&amp;quot; RT-spot).&lt;br /&gt;
&lt;br /&gt;
For both types, the user has access to most of the modules (&amp;quot;Color and Light&amp;quot;, &amp;quot;Contrast by detail levels&amp;quot;, &amp;quot;Blur&amp;quot;, ...)&lt;br /&gt;
&lt;br /&gt;
====Comments about the &amp;quot;excluding&amp;quot; RT-spot====&lt;br /&gt;
* The principle of the &amp;quot;excluding&amp;quot; spot is similar to the &amp;quot;counterpoint&amp;quot; in Capture NX2, and is useful when for example, the effect of a &amp;quot;normal&amp;quot; RT-spot bleeds into an area which the user wants to be unaffected. This unwanted effect happens when when the tints of the two areas (the area the user wants to be affected, and the area one wants to remain unaffected) are to close.&lt;br /&gt;
* The underlying algorithm is similar to the main algorithms used elsewhere in &amp;quot;locallab&amp;quot;, and is based on tint differences. While it's not perfect it should give satisfaction 70% of the time.&lt;br /&gt;
* I implemented an additional algorithm (with no guarantee that it will actually work one day) to help discriminate the areas, based on a Sobel-Canny transform. The transform is coded but is not yet accessible to the user, as I'm still working to make it more efficient.&lt;br /&gt;
&lt;br /&gt;
====How to use the &amp;quot;excluding&amp;quot; RT-spot, and its limitations====&lt;br /&gt;
# Create a new RT-spot over the area you want to restore.&lt;br /&gt;
# In the &amp;quot;Settings&amp;quot; panel, from the &amp;quot;Spot method&amp;quot; combobox choose &amp;quot;Excluding spot&amp;quot;.&lt;br /&gt;
# Adjust &amp;quot;Scope&amp;quot;, &amp;quot;Transition&amp;quot; and &amp;quot;Spot size&amp;quot; as well as the shape of the zone of influence using the 4 handles, until you get the desired reversion of the effect. You can use complimentary adjustments such as &amp;quot;Color and light&amp;quot;, etc.&lt;br /&gt;
The algorithm computes the reference values (tint, chroma, luma) from the the current image (see below). As a consequence, the &amp;quot;excluding&amp;quot; effect won't work if the image area is black (for example when the user uses a normal RT-spot using &amp;quot;Color and light&amp;quot; in inverse mode to create a black frame).&lt;br /&gt;
Sometimes, when the &amp;quot;inverse&amp;quot; mode is selected, the &amp;quot;excluding&amp;quot; spot algorithm may not work as expected and lead to a difference between the preview and the output (JPG, TIFF) image. Increasing the value of &amp;quot;Scope&amp;quot; of the &amp;quot;excluding&amp;quot; RT-spot should help in this situation.&lt;br /&gt;
&lt;br /&gt;
===Tint, chroma, luminance references and the algorithm principle in “normal” mode===&lt;br /&gt;
In order to develop an efficient shape detection algorithm:&lt;br /&gt;
* The central circle zone is used as the reference. Based on the diameter value chosen by the user, the algorithm computes the tint (hue), chroma and luminance averages.&lt;br /&gt;
* The choice of the central zone diameter depends on the use intent. For example, if working on a foliage area the user would benefit from choosing a smaller diameter value in order to select only the foliage green; in contrast, for skin tones the user should increase the diameter to avoid the detection of parasites (noise, eye lashes…).&lt;br /&gt;
* For each quadrant, depending on the the value of the “Scope” slider, the algorithm does:&lt;br /&gt;
# take into account the tint difference between the zone centre and the affected pixel;&lt;br /&gt;
# through a complex algorithm based on the deltaE notion (perceived difference between two colours, taking tint, chroma and luminance into account), decrease the amount of applied effect as a function of the difference between the central zone and the affected pixel;&lt;br /&gt;
# follow either a linear or a parabolic law to adjust the amount of applied effect, based on the specific the case.&lt;br /&gt;
&lt;br /&gt;
This allows adapting the amount of effect according to the above-mentioned criteria. For example, if the central circle is located on foliage, the action will be limited to the leaves, without touching the background (which would be impossible to obtain with the lasso type of controls). Additionally, if some other foliage resides within the area covered by the RT-spot, it will also be affected.&lt;br /&gt;
* Adjusting the value of the “Transition” slider modifies the transition of the effect (from the centre to the edge): on 50, the inner (linear) half will get the full 100% action/effect, while the effect in the outer half will gradually transition from 100% to 0% towards the edge;&lt;br /&gt;
* By increasing the value of “Scope”, progressively more of the selected area is taken into account, whatever the tint, chroma and luminance;&lt;br /&gt;
* Conversely, by decreasing the “Scope” value the effect will get limited to the pixels which are more similar (in terms of deltaE) to the reference zone.&lt;br /&gt;
&lt;br /&gt;
The shape detection algorithm works in “Normal” mode except for some modules (“Denoise”). It’s not implemented in “Inverse” mode, doing so would not make sense.&lt;br /&gt;
&lt;br /&gt;
The algorithm will see its performance increase when the user chooses “Enhanced” or “Enhanced + chroma denoise” in the “Global quality:” combobox. The second choice additionally applies a low amount of chroma noise reduction in order to get rid of artefacts which could be brought up by the “Enhanced” algorithm (note that the chroma denoise step increases memory use and computing time).&lt;br /&gt;
&lt;br /&gt;
The algorithm is used in full capacity for “scope” &amp;lt; 20.&lt;br /&gt;
&lt;br /&gt;
===Why no alternative algorithms?===&lt;br /&gt;
It should be possible to implement other shape detection algorithms than the deltaE-based one used currently, for example:&lt;br /&gt;
* edge detection algorithms such as “Canny” or “Sobel”;&lt;br /&gt;
* wavelet decomposition.&lt;br /&gt;
&lt;br /&gt;
But in both cases, everything would have to be done!&lt;br /&gt;
&lt;br /&gt;
===Functioning in “inverse” mode===&lt;br /&gt;
When it is available, the “Inverse” mode is extremely simplified: only the “Transition” slider can be used to apply the effect.&lt;br /&gt;
As of late October 2017, I devised a new method for “Inverse” mode. It is limited to the “Blur &amp;amp; Noise” module (see the corresponding section below).&lt;br /&gt;
&lt;br /&gt;
===Maximum number of RT-spots===&lt;br /&gt;
By default the number of available RT-spots is 8. You can choose any number between 2 and 499. For this you only need to change the parameter “Nspot” in the “options” file (for example: Nspot=12). Restart RawTherapee for the modification to be taken into account.&lt;br /&gt;
&lt;br /&gt;
===The “super” algorithm===&lt;br /&gt;
The key to “success” was the algorithm implemented in late January 2017, which works this way:&lt;br /&gt;
# on the pixel data which are within the area covered by the RT-spot, the algorithm applies either a “traditional” curve, a slider, or a normal transfer function (“Retinex”, “Tone Mapping”, “Contrast by detail levels”, “Vibrance”, …);&lt;br /&gt;
# the LUT or the transfer function is converted into an equivalent of a slider, separating negative and positive values so that the function can be viewed as multiple sliders (as many sliders as there are pixels) in the -100, 0, +100 interval;&lt;br /&gt;
# the data are passed to the shape detection function – the 4 quadrants. For every pixel, the difference in terms of tint, chroma and luma is computed with regards to the central reference. The linear variation equations are estimated for luminance (L=f(L)), chroma (C=f(C)) or transfer functions;&lt;br /&gt;
# different corrections are applied to account for the environment (sky, skin tones…)&lt;br /&gt;
# a correction is made (with threshold and iterations) in order to avoid correcting (or only slightly, based on the user’s choice) the grey or neutral tones which are in the same tint as the reference (but with a low chroma value);&lt;br /&gt;
# the parameters are weighted based on the shape of the RT-spot (ellipses) and the transition zone;&lt;br /&gt;
# the values of the “Global quality:” parameters are important, particularly so for images with a low amount of noise – chroma noise is interpreted by the algorithm being of the same colour as the spot. It is thus necessary to suppress this noise, that is the purpose of “Enhanced + chroma denoise” (this algorithm may not be sufficient, though – in this case using the local “Denoise” module may be useful).&lt;br /&gt;
&lt;br /&gt;
This new (“super”) algorithm seems to perform generally well, but in the event when the RT-spot is located in a grey/neutral or flat area, the algorithm may fail. In such cases, using the old algorithm is recommended (except for “Retinex”, “Tone Mapping” and “Contrast by detail levels” for which it is made unavailable for the sake of code simplicity).&lt;br /&gt;
&lt;br /&gt;
===Artefact reduction and the “Global quality” algorithms===&lt;br /&gt;
By default, “Global quality:” is set to “Enhanced + chroma denoise”. Whereas it increases computation time, it is still generally preferable. In case one wants a more responsive preview, “Enhance” or “Standard” can be chosen (good for exploring the image).&lt;br /&gt;
* two sliders allow reducing artefacts and improving the algorithm’s rendering. They work based on chroma, in neutral/gray tones. To completely remove its effect, one can simply set “iterations=0”. These sliders may be used for &amp;quot;Color light&amp;quot;, &amp;quot;Exposure&amp;quot;, &amp;quot;Retinex&amp;quot;, &amp;quot;Vibrance&amp;quot;, &amp;quot;Tone mapping&amp;quot; and &amp;quot;Contrast by detail levels&amp;quot;;&lt;br /&gt;
* for (even slightly) noisy images, the algorithms may be misled. In this case it is recommended to keep &amp;quot;Global quality:”  set to “Enhanced + chroma denoise&amp;quot;, and (sometimes) activate the local “Denoise” module and adjust the sliders very gently (including “Luminance”);&lt;br /&gt;
* under some circumstances, with “Tone Mapping” for example, the artefact reduction algorithm may actually generate more artefacts. When it happens, set “iterations=0”.&lt;br /&gt;
&lt;br /&gt;
If your images are generally clean (no or very low noise), you can choose to have “Standard” as the default for “Global quality:” – this will speed up the image processing. To do so, go to “Preferences” &amp;gt; “Performance and quality” tab &amp;gt; “Local adjustments” and choose the “Standard” algorithm among the 3 options. This will become the new default  when new RT-spots are created, but of course the algorithm can still be changed on the fly by choosing from the “Global quality” combo box.&lt;br /&gt;
&lt;br /&gt;
===Avoid color shift===&lt;br /&gt;
The “Avoid color shift” checkbox serves two purposes:&lt;br /&gt;
* put the colours within the current working profile gamut, using a relative colorimetry;&lt;br /&gt;
* adjust colours using a “Munsell” correction – particularly for red-orange and blue-purple colours, when saturation in the L*a*b* space has changed significantly.&lt;br /&gt;
&lt;br /&gt;
===“mip” files – Principles of the multi-point algorithm===&lt;br /&gt;
For the local control system to work and keep track of RT-spot objects, a text file – similar to a pp3 – is written in 2 possible places:&lt;br /&gt;
* next to the edited image file. If, for example, you edit an image named ASC4509.NEF, a new file named ASC4509.NEF.mip will be generated in the same folder. In this case, several sessions can be open for the same image, as long as copies of the image are stored in different folders. However, the folder names in the path have to contain ASCII characters only, otherwise it will make the program crash;&lt;br /&gt;
* in the dedicated “mip” folder, within the “cache” directory (through an MD5 hash number which identifies the file). This is the default. If chosen, when multiple copies of the same file exist in distinct folders, editing them creates as many “mip” files. This option allows the use of non ASCII characters in the folder names and path.&lt;br /&gt;
&lt;br /&gt;
The choice between these two behaviours is made in “Preferences” &amp;gt; “Image processing” tab &amp;gt; “Mip profiles”.&lt;br /&gt;
&lt;br /&gt;
The “mip” files contain the data which are passed to RawTherapee through processes of the “procparams” type, and LUTs which allow editing in zoom mode. When updating RawTherapee to a new version, it may be required to delete the “mip” files (or the whole cache) to avoid a potential crash of the application. This can be achieved by going to “Preferences” &amp;gt; “File browser” tab, then choosing “Clear mip” and/or “Clear pp3” – all this is valid only if “mip” and “pp3” files have been set to be saved to the cache folder, otherwise they will have to be manually deleted from the working folder. Keeping older “mip” and “pp3” files may lead to instability or crashes of the application.&lt;br /&gt;
&lt;br /&gt;
====Architecture of the filter====&lt;br /&gt;
When I “ventured” into a multi-point, no-layer and no-mask system, code duplication had to be avoided. Indeed, it is unthinkable to consider, for 10 RT-spots, generating 10 GUI code blocks, and just as many code blocks in “rtengine”. After careful consideration, the idea was to have a file updating and tracking in real time – i.e. a file which would follow each modification made by the user – the actions/modifications history.&lt;br /&gt;
&lt;br /&gt;
Of course, the parameters used by RawTherapee for the GUI and for the main code through “params” are of different types:&lt;br /&gt;
* numeric: integer, float, double,…&lt;br /&gt;
* Boolean&lt;br /&gt;
* string (in choice menus for the different modules)&lt;br /&gt;
* curves, through “vectors” of type double with dynamic dimension&lt;br /&gt;
* …&lt;br /&gt;
&lt;br /&gt;
====Data conversion====&lt;br /&gt;
In order to simplify data management, the first step is to convert all data to integers. Sometimes this can lead to a slight precision loss, which I think is negligible.&lt;br /&gt;
* This operation is very simple for numeric values, even though in some cases (such as hue, which is expressed in radian in the interval [-Pi, +Pi]) it needs a double “float*100 and /100 conversion to keep precision.&lt;br /&gt;
* It is logical for Boolean operations and methods.&lt;br /&gt;
* However, it is a complex matter regarding curves. The values to be recorded in the “mip” file are of type vector&amp;lt;double&amp;gt;, in a dynamic table of numeric values. There may be a simpler way, by using existing functions from “procparams”, but I didn’t succeed. &lt;br /&gt;
Nevertheless, I could get around this by:&lt;br /&gt;
# converting doubles to integers with 3 significant figures – which is largely enough,&lt;br /&gt;
# then converting the “vector” to a variable length character string,&lt;br /&gt;
# the writing and reading of this character string and converting to a vector dynamically using an appropriate function (”strcurv_data”). Note that this function allows adjusting the curves within the limit of 16 inflection points (Bézier curve) for the flat curve, and 32 points for the diagonal, which should be enough. Whether this would not be enough, it should be possible to increase that number, though compatibility would be compromised.&lt;br /&gt;
&lt;br /&gt;
====Some elements about curves====&lt;br /&gt;
The implementation of curves has been a complex task, particularly since:&lt;br /&gt;
# each curve needs its own reset function – resize() at each iteration,&lt;br /&gt;
# which implies oddities regarding their description, for example the diagonal curve gets initialised with several points, despite it looks being “empty”. This is mandatory for correct functioning, but this means that the curve is always open/active. Consequently, to avoid some unwanted loss of computation time in “preview” mode, the user has to activate the curve by clicking on the “curves” combobox. The same activation is necessary for L=f(H) and C=f(C) curves. While clicking enabling the “curves” (linear) would seem to be a better solution, it didn’t work despite many trials.&lt;br /&gt;
# during all the procedure, we need to set each &amp;quot;params&amp;quot; value to &amp;quot;clear&amp;quot; for curves, for each LUT, at each iteration and then through a &amp;quot;vector&amp;quot; to reassign the good, updated values to &amp;quot;curve params&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
====Data storing and dynamic use====&lt;br /&gt;
Once data have been converted:&lt;br /&gt;
* they are stored in a text (mip) file,&lt;br /&gt;
* each one is referenced inside a 2-dimension dynamical table:&lt;br /&gt;
# dataspot[x][y] for numeric and boolean values and methods, where “x” is the representative index of the parameter (e.g. “9” is for “lightness”) and “y” represents the current RT-spot (control spot). Value “0” represents the current in-use value (the one stores in “params”).&lt;br /&gt;
# retistr[y], llstr[y], lhstr[y], ccstr[y], hhstr[y], skinstr[y], pthstr[y], exstr[y] for parameters of type “curve”. Currently there are only 8 parameters, used for local “Retinex”, “Color and light” (L=f(L), C=f(C), L=f(H), H=F(H)), “Vibrance” and “Exposure”, but it is easy to add more. “y” is used as above in 1.&lt;br /&gt;
&lt;br /&gt;
The way data are stored and used fits well with improccoordinator.cc (current management / preview) and simpleprocess.cc (TIFF / JPG  output) files, but not so with dcrop.cc and the partial display of the image (RawTherapee’s pipeline).&lt;br /&gt;
&lt;br /&gt;
In this case (zoom / preview) another solution had to be found in order to synchronise the modifications in real time. I made use of LUTs, so that to each entry referenced in the table described above a LUTi(z) is associated, with z=500 possible entries (500 corresponds to the current maximum number of RT-spots, but this limit can be decreased or increased). The LUTi “z” corresponds to the dataspot “y”. A 25,000 entries LUTi (arbitrary number) is used for “retistr”, “llstr”, “lhstr”, “ccstr”, “hhstr”, “skinstr”, “pthstr”, “exstr” for storing each “vector” curve value in memory (up to 69 values stored as integers).&lt;br /&gt;
&lt;br /&gt;
During data processing, exchanges occur between: params, dynamic tables and LUTi. The values used by dcrop.cc are dynamically linked to dynamical tables by parent→.&lt;br /&gt;
&lt;br /&gt;
====Exchange processes and dynamic data storing====&lt;br /&gt;
# reading of the “mip” file to check the version number and guide the updates&lt;br /&gt;
# creating the “mip” file if it doesn’t exist&lt;br /&gt;
# storing the data in LUTi and dynamic tables from the values stored in “params” (index 0 values)&lt;br /&gt;
# first interactive update with the GUI through a transfer function between “rtengine” and locallab.cc (aloListener → localretChanged). This is one of the 3 functions required for the process to work correctly&lt;br /&gt;
# reading of the “mip” file and data storing in dynamic tables (index values ==&amp;gt; y) according to the number of RT-spots&lt;br /&gt;
# creating a loop – according to the number of RT-spots – which updates LUTi (required by “dcrop”) and “params” values from values stored in the dynamic tables&lt;br /&gt;
# call to the “Lab_local” function which contains the algorithms controlling each RT-spot (luminance, sharpness, retinex, denoise, …)&lt;br /&gt;
# second interactive update with the GUI through another transfer function between “rtengine” and “locallab.cc”&lt;br /&gt;
# treatment of the current RT-spot by using the index (0) values from the dynamic tables. These values are attributed to 1) “params”, 2) LUTi and 3) current index values&lt;br /&gt;
# call to the “Lab_local” function for the current RT-spots&lt;br /&gt;
# saving to the “mip” file.&lt;br /&gt;
&lt;br /&gt;
Note that if the user modifies the curve (amplitude, number of inflection points) a third interactive update is made in order to conform all of the data according to events.&lt;br /&gt;
&lt;br /&gt;
====A few unavoidable “fantasies”====&lt;br /&gt;
Of course everything looks simple, the process works if, and only if, all the data are dynamically updated. I’ve tried a lot, went groping, and finally found a working solution… but an uncanny one. There’s probably a more “informatically” correct way to do it, but at this point I’ve done as explained above and hereafter.&lt;br /&gt;
&lt;br /&gt;
The 3 exchanges between “rtengine” and the GUI occur with 3 parameters which actually do nothing in the program except doing the update process:&lt;br /&gt;
# “anbspot” which takes values of 0 or 1&lt;br /&gt;
# “cTgainshaperab” (curve) which takes any value bewteen 0.70 and 0.90&lt;br /&gt;
# “retrab” which varies around 500.&lt;br /&gt;
I have added 3 more parameters (in the form of sliders) – hueref, chromaref and lumaref – hidden from the user but which are used to update the system in real time, to correctly take into account the reference “spot” values. Allowing those 3 parameters to vary brings stability and allows real time updates. Increasing the number of those “fantasy” parameters should not be necessary. These extra parameters are hidden to the user, and are only visible in the history.&lt;br /&gt;
&lt;br /&gt;
In addition, I had to add some empirical time delays, giving time to time… Time delay is used for example when the user modifies the curve (amplitude, number of inflection points).&lt;br /&gt;
&lt;br /&gt;
==Specificity of the local mode (as compared to “Lab adjustments”)==&lt;br /&gt;
Hereafter is some useful information for the user, often specific to the local mode.&lt;br /&gt;
&lt;br /&gt;
===Color and Light===&lt;br /&gt;
 * The algorithms used for luminance and contrast in local mode differ from the ones used in “Lab adjustments”, which may lead to differences in rendering.&lt;br /&gt;
* The luminance algorithm is made such that below -90 and down to -100 for “Lightness”, it is possible to increase the image's “darkness”, almost to the point of getting a luminance value close to 0. To accentuate this effect, “Chrominance” can be decreased and “Scope” increased.&lt;br /&gt;
* The inverse mode can be used for creating graduated frames. If “Ligthness” is set to -100 and &amp;quot;Chrominance&amp;quot; is reduced, the “frame border” will be black.&lt;br /&gt;
* For the “Lightness” and “Contrast” sliders, the user can choose among 2 algorithms: the first one (default) is close to that in “Lab adjustments” while the second one, activated through “Lightness - Contrast ‘Super’” is close to the algorithm used for the L=f(L) “Super” curve.&lt;br /&gt;
* Do not hesitate, when needed, to activate “Enhanced” or “Enhanced + chroma denoise” in the “Global Quality:” combobox.&lt;br /&gt;
&lt;br /&gt;
====Curves====&lt;br /&gt;
* An L=f(L) or C=f(C) curves allow controlling the luminance and chrominance for each RT-spot as a function of luminance or chrominance.&lt;br /&gt;
* An L=f(H) curve allows controlling the luminance for each RT-spot as a function of tint.&lt;br /&gt;
* An H=f(H) curve allows controlling the tint for each RT-spot as a function of tint.&lt;br /&gt;
The curves are activated by selecting one of the two algorithms from the “Curves types” combobox:&lt;br /&gt;
* “Normal”: the curves – particularly the one that is the most difficult to manage, L=f(L) – use an algorithm close to the one used with the sliders (Normal mode),&lt;br /&gt;
* “Super”: using a new algorithm, which I think performs very well (it even surprised me the first time I used it).&lt;br /&gt;
&lt;br /&gt;
Caution: when the RT-spot resides in an area which is neutral, grey or very uniform, the artefacts introduced by the new algorithm (“Super” algorithm for the curve or the slider) may be impossible to get rid of. Use one of the 2 older algorithms to avoid that.&lt;br /&gt;
&lt;br /&gt;
===Exposure===&lt;br /&gt;
The “Exposure” module may look like the the one in global RGB mode, but:&lt;br /&gt;
* it works entirely in L*a*b* mode, hence the differences in rendering;&lt;br /&gt;
* there’s no “Lightness”, “Chroma” or “Contrast” slider, whose functions are already fulfilled in the “Color and Light” module;&lt;br /&gt;
* there’s only one “Contrast” curve, similar to the L=f(L) firm “Color and Light”. Of course its effect is different from “Tone curve” which works in RGB mode. If needed, two L=f(L) curves can be activated, one under “Color and Light” and the other under “Exposure”.&lt;br /&gt;
&lt;br /&gt;
===Vibrance===&lt;br /&gt;
This module is similar to the main one (from RawTherapee's &amp;quot;Exposure&amp;quot; tab).&lt;br /&gt;
&lt;br /&gt;
===Blur &amp;amp; Noise===&lt;br /&gt;
“Blur” is activated only when “Radius” =&amp;lt; 2.&lt;br /&gt;
By significantly lowering the default value of “Scope” and possibly checking “Blur luminance only”, it is possible to get a different amount of blur for the different tints.&lt;br /&gt;
Since October 2017, 3 methods are proposed:&lt;br /&gt;
* “Normal”: the shape detection algorithm has been improved, it is now closer to shape detection algorithm proposed in the other modules;&lt;br /&gt;
* “Inverse”: a simplified algorithm, which doesn’t make use of “Scope”. The inversion is coarse and doesn’t allow a fine separation between the affected and unaffected areas;&lt;br /&gt;
* “Symmetric”: this new algorithm uses the same processes as “Normal”, and adjusting “Scope” the user can target the process with more precision.&lt;br /&gt;
Caution: &lt;br /&gt;
* Using the “Inverse” mode will blur large portions of the image, which can not be corrected later on.&lt;br /&gt;
* The action of “Scope” may sometimes appear puzzling: for instance, in a portrait, the eyes (which of course differ from the skin) may be blurred if the value of “Scope” is too low.&lt;br /&gt;
&lt;br /&gt;
===Tone Mapping===&lt;br /&gt;
Caution when uniformly coloured areas (sky, grey/neutral zones) have a similar tint to the area on which the RT-spot is placed. In cases where this leads to artefacts, set the “Iterations” slider to 0 in “Settings” &amp;gt; “Reduce artefacts – Improve algorithm”.&lt;br /&gt;
&lt;br /&gt;
===Retinex===&lt;br /&gt;
Compared to the standard “Retinex” module, the local “Retinex module has simplified controls, and is applied at the end of the pipeline instead of the beginning. Since “mip” version 10002, the “Transmission gain” is specific to each RT-spot.&lt;br /&gt;
&lt;br /&gt;
===Sharpening===&lt;br /&gt;
Only the “RL Deconvolution” algorithm is provided here.&lt;br /&gt;
&lt;br /&gt;
===Contrast by detail levels===&lt;br /&gt;
Compared to the main RGB mode module, this one has:&lt;br /&gt;
* 5 levels instead of 6,&lt;br /&gt;
* no slider for “skin tone” protection (not needed since the algorithm works locally on the RT-spot area),&lt;br /&gt;
* an additional “Chroma” slider.&lt;br /&gt;
&lt;br /&gt;
Caution when uniformly coloured areas (sky, grey/neutral zones) have a similar tint to the area on which the RT-spot is placed. In cases where this leads to artefacts, set the “Iterations” slider to 0 in “Settings” &amp;gt; “Reduce artefacts – Improve algorithm”.&lt;br /&gt;
&lt;br /&gt;
===Denoise===&lt;br /&gt;
Compared to the main RGB mode module, this one has:&lt;br /&gt;
* only the wavelet tool working (no Fourier function, nor medians),&lt;br /&gt;
* less sliders and curves,&lt;br /&gt;
* the possibility to work differentially on fine or coarse noise for both luminance and chrominance noise.&lt;br /&gt;
&lt;br /&gt;
==A specific use case : reduction of image defects (dirty sensor, red eyes, …)==&lt;br /&gt;
“Locallab” had not been thought with the idea of correcting small image defects. However, some visible, “photographically disturbing” defects may actually be tamed or even removed. Of course, this is not incompatible with other more specialised modules which could be introduced (or not) into “Locallab”… At least 3 existing modules can serve this purpose, alone or in combination, by adapting their use:&lt;br /&gt;
* “Color and Light” for spot-like defects;&lt;br /&gt;
* “Contrast by detail levels” for spread out defects;&lt;br /&gt;
* “Blur and Noise” as an optional complement (caution, this is a destructive action, use moderately).&lt;br /&gt;
&lt;br /&gt;
These modules can be used either on the main image (raw, TIFF,  …) or on a flat-field image.&lt;br /&gt;
&lt;br /&gt;
===Using the “Color and Light” module===&lt;br /&gt;
* Activate “Color and Light”&lt;br /&gt;
* A red eye removal tool equivalent can be obtained by framing closely around the eye – central circle zone centered on the eye’s red, spot handles close to the eye – low “Scope” value, then lowering “Lightness” and “Chrominance” to -100.&lt;br /&gt;
* The same idea allows reducing the “IR spot” kind of defect by framing closely around the defect – central circle zone centred on the defect, spot handles close to the defect area – then lowering “Chrominance” to taste, and if needed lowering the “scope” value.&lt;br /&gt;
* In some (simple) situations, a “dirty sensor” defect can be reduced, in particular in the case of “sensor grease”. It can be seen as stains or spots on a uniform background. To attenuate this, choose a tight framing of around the defect – central circle on the centre of the defect (adapt the size of the RT-spot), drag the handles so that they are not too close to the border of the defect (this will make the transition less noticeable). Then: a) decrease “Transition” towards lower values; b) check “Lightness - Contrast “Super”; c) adjust “Lightness” and “Chrominance” as needed to bring the defect area closer to the unaffected area; d) if needed adjust slightly “Scope” to achieve the best result.&lt;br /&gt;
&lt;br /&gt;
===Using the “Contrast by detail levels” module===&lt;br /&gt;
When the sensor is dirty (grease), and when the affected area is large or if there are multiple small defects, “Contrast by detail levels” may be used, working as a sort of “wavelet” tool on luminance, and if needed on chrominance. In such cases: a) place the RT-spot on one of the stronger defects (adjust the size as needed); b) drag the handles so as to cover most of the affected area; c) set “Transition” to higher value; d) activate “Contrast by detail levels” and decrease the contrast of levels 3 and 4 (or lower); you can adjust the “Chroma” slider if needed.&lt;br /&gt;
&lt;br /&gt;
==Settings in the Preferences dialog==&lt;br /&gt;
Below is a list of the settings (already mentioned above in several places) which can be accessed from the “Preferences” dialog:&lt;br /&gt;
* In “Preferences” &amp;gt; “General” tab &amp;gt; “Local adjustments”, by checking the “Show spot delimiters” checkbox, an approximate zone delimitation is drawn which helps viewing the area affected by the RT-spot and its settings.&lt;br /&gt;
* If your images generally have low noise, you can set the default for “Global quality” to “Standard”, and get a significant speedup in processing time. This setting is found under “Preferences” &amp;gt; “Performance &amp;amp; Quality” tab &amp;gt; “Local adjustments”. The three choices for quality are selected from the “Local adjustments Quality method” combobox. Default is “Enhanced + chroma denoise”.&lt;br /&gt;
* Regarding “mip” files:&lt;br /&gt;
** the choice for “mip” files destination folder is set from “Preferences” &amp;gt; “Image processing” tab &amp;gt; “Mip Profiles”;&lt;br /&gt;
** in order to clean the generated “mip” profiles, go to “Preferences” &amp;gt; “File Browser” tab &amp;gt; “Cache Options” and click on the “Clear mip” button and/or “Clear pp3” – this is valid in the case where you chose to store “mip” files in the cache, otherwise if you chose to let RT write the “mip” files next to the input file, you will have to delete them manually. Note that the presence of older versions of “mip” and “pp3” files may lead to instability or even crashes of RawTherapee.&lt;br /&gt;
&lt;br /&gt;
==Processing time and memory use==&lt;br /&gt;
At image export time (output to JPG, TIFF…), for the “normal” mode, the algorithms compute the data only for in the RT-spot delimited areas, not for the whole image. Thus, processing time and memory stay reasonable. Note that of course, this will depend on the number of RT-spots, their size, and the type(s) of treatment done in these RT-spots.&lt;br /&gt;
&lt;br /&gt;
Excluding “Denoise” and “Sharpen”, processing time is in the order of a few tenths of a second per RT-spot, and memory use of a few hundred MB.&lt;br /&gt;
&lt;br /&gt;
Two settings have a strong influence on resource use:&lt;br /&gt;
    • “Denoise” which adds around 1 sec. of processing time, and 1 MB of memory use;&lt;br /&gt;
    • “Global quality: Enhanced + chroma denoise” which adds around 0.5 sec. And 0.6 MB.&lt;br /&gt;
These figures depend on the size of the RT-spot.&lt;br /&gt;
&lt;br /&gt;
==Future evolution==&lt;br /&gt;
Besides usual tweaking, bug corrections, improvements (settings, user interface)… it would be desirable to improve the GUI with regards to the creation/selection/modification of individual RT-spots.&lt;br /&gt;
&lt;br /&gt;
From a programming point of view, it should be possible to improve code readability and maintainability, and to integrate all the “mip” files code parts (as done in “rgbproc.cc”) which currently are linearly integrated to void procedures in “improccoordinator.cc”, “dcrop.cc” and “simpleprocess.cc”.&lt;/div&gt;</summary>
		<author><name>Sguyader</name></author>
	</entry>
	<entry>
		<id>http://rawpedia.rawtherapee.com/index.php?title=Local_Adjustments/fr&amp;diff=3344</id>
		<title>Local Adjustments/fr</title>
		<link rel="alternate" type="text/html" href="http://rawpedia.rawtherapee.com/index.php?title=Local_Adjustments/fr&amp;diff=3344"/>
		<updated>2017-11-10T13:47:57Z</updated>

		<summary type="html">&lt;p&gt;Sguyader: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Quel type de contrôle local? ==&lt;br /&gt;
Lorsqu'on observe les différents logiciels du marché on trouve plusieurs types de contrôles locaux&lt;br /&gt;
# les contrôles de type &amp;quot;lasso&amp;quot;, associés à des calques et masques de fusion, comme par exemple dans Photoshop (c). Ce type de contrôle est majoritaire dans les logiciels (Photoshop, Gimp, Darktable...) et l'avis des utilisateurs est obligatoirement orienté vers ceux-ci au détriment du point 3) ci-dessous moins connu!&lt;br /&gt;
# les dispositifs de suppression de &amp;quot;yeux rouges&amp;quot;, ou de &amp;quot;spot&amp;quot; liés aux imperfections du capteur&lt;br /&gt;
# les contrôles de type U-points, utilisés jusque récemment dans Nikon Capture NX2 (c), ou comme complément à d'autres logiciels comme Nik Software (c). Pour qui a tâté de ces dispositifs (rares maintenant) il n'est pas question de revenir aux calques et masques de fusion! Ce type de contrôle nécessite un apprentissage différent de ceux de type lasso-calque et un désapprentissage cognitif de ceux-ci. De mon point de vue, ils sont globalement plus performants.&lt;br /&gt;
&lt;br /&gt;
Dans la version présente de Rawtherapee, l’algorithme développé est proche dans le principe du point 3) ci-dessus, les U-points. Bien sûr, le code de Nik Software est inconnu, mais il y a quelques années j'ai été séduit par la facilité d'utilisation et les performances des U-points, et j'ai entrepris de développer un produit qui ne ferait pas appel, ni au lasso, ni aux calques, ni aux masques de fusion.&lt;br /&gt;
&lt;br /&gt;
Bien sûr rien n'interdit d'avoir les 3 possibilités (Lasso-calque, retouches spot, U-points) !&lt;br /&gt;
&lt;br /&gt;
La version actuelle est très certainement perfectible, au niveau de l'interface graphique - GUI - notamment:&lt;br /&gt;
* pour le suivi et repérage des RT-spot (spot de contrôle) à l'écran&lt;br /&gt;
* pour les réglages des différents curseurs qui gagneraient à être intégrés au spot de contrôle, comme le fait Nik Software (c).&lt;br /&gt;
Cependant, ces deux points n'affectent pas ni l’utilisation courante, ni la portabilité.&lt;br /&gt;
&lt;br /&gt;
J'ai ajouté, pour faciliter l'utilisation et éviter les menus trop longs en mode écran, une interface GUI similaire à celle de Wavelet, avec des &amp;quot;expanders&amp;quot;.&lt;br /&gt;
Vous avez ainsi la possibilité pour chaque famille d'action (color and light, Blur, Retinex, etc.):&lt;br /&gt;
# faire apparaître ou non le détail des commandes : curseurs, méthodes, courbes,..&lt;br /&gt;
# activer ou non l'ensemble des fonctions de la famille d'action.&lt;br /&gt;
Attention, le choix - 2 - active ou annule l'ensemble des RT-spot ( spot de contrôle); il est théoriquement possible d'associer cette possibilité à chaque RT-spot, mais quel intérêt ? &lt;br /&gt;
&lt;br /&gt;
===Contrôles locaux Lab et RGB===&lt;br /&gt;
* Les premiers algorithmes sont écrits en mode L*a*b* avec les contrôles suivants : &amp;quot;Color and Light&amp;quot;, &amp;quot;Blurr addnoise&amp;quot;, &amp;quot;Retinex&amp;quot;, &amp;quot;Tone mapping&amp;quot;, &amp;quot;Sharpen&amp;quot;, &amp;quot;CBDL&amp;quot;, &amp;quot;Denoise&amp;quot;..Deux contrôles suivants ont été ajoutés : &amp;quot;Exposure&amp;quot;, &amp;quot;Vibrance&amp;quot;...&lt;br /&gt;
* Voir ci-dessous le principe des algorithmes, mais un des points clefs à retenir pour la détection de forme et la prévention des artefacts est que le mode Lab préserve la teinte &amp;quot;hue&amp;quot;, qui joue un rôle déterminant.&lt;br /&gt;
* L'idée d'un module &amp;quot;RGB&amp;quot; vient évidemment à l'esprit, avec ''a minima'' un module :&lt;br /&gt;
** White Balance : qui permettrait une retouche de la balance des blancs par exemple pour &amp;quot;réchauffer les parties à l'ombre&amp;quot;, ou permettre le mélange de deux éclairages par exemple &amp;quot;lumière du jour&amp;quot; et &amp;quot;Tungsten&amp;quot;. Ce module doit être placé juste après &amp;quot;demosaic&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
====White balance auto====&lt;br /&gt;
Le module &amp;quot;white balance&amp;quot; (branche &amp;quot;autowblocal&amp;quot;) vise deux objectifs :&lt;br /&gt;
* permettre la retouche locale de la Balance des blancs (évident!)&lt;br /&gt;
* tester de nouveaux algorithmes de Balance des blancs automatique :&lt;br /&gt;
** en usage général (full image), afin d'obtenir de meilleurs résultats que l'algorithme actuel. Bien sûr on va me rétorquer qu'il faudrait une branche spécifique &amp;quot;White balance&amp;quot;, mais j'essaie de faire d'une pierre deux coups.&lt;br /&gt;
&lt;br /&gt;
Pour mémoire en 2012 et 2013, il m'avait été demandé, de mettre en place la balance des blancs itérative &amp;quot;Auto Robust WB[http://ieeexplore.ieee.org/document/1649677/]&amp;quot;. A l'époque avec un autre développeur nous avons passé beaucoup de temps pour un résultat assez peu satisfaisant... d'où l'abandon. Depuis, fort de cette expérience j'ai repris le travail mais à l'envers ! Maintenant - si je ne me suis pas trompé - l'algorithme fonctionne.&lt;br /&gt;
J'ai profité de cette possibilité (actuellement uniquement pour des images RAW), pour rechercher dans la littérature universitaire, d'autres algorithmes auto. J'ai trouvé et mis au point deux nouveaux algorithmes :&lt;br /&gt;
* &amp;quot;auto edge[https://www.researchgate.net/publication/301419990_A_Method_to_Improve_Robustness_of_the_Gray_World_Algorithm]&amp;quot; : l'idée ici est de créer un masque d’accentuation pour permettre de renforcer les parties de l'images où il y a des détails par rapport aux aplats.&lt;br /&gt;
* &amp;quot;auto standard deviation[http://www.acad.bg/rismim/itc/sub/archiv/Paper3_1_2012.pdf]&amp;quot; : l'image (ou la partie d'image pour le mode local) est divisée en 12 zones. Pour chacune on calcule moyenne et écarts type, puis on assemble le résultat.&lt;br /&gt;
Un troisième algorithme semble prometteur &amp;quot;Color by correlation[https://courses.cs.washington.edu/courses/cse467/08au/labs/l5/whiteBalance.pdf]&amp;quot;, mais je me heurte à quelques difficultés...Après beaucoup de tests en tous genres, les résultats sont erratiques...&lt;br /&gt;
&lt;br /&gt;
J'ai ajouté la notion de gamma:&lt;br /&gt;
* les mêmes principes concernant la répartition de la luminance - gamma sRGB - utilisé dans le code de Rawtherapee&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A titre de rappel, la balance des blancs automatique est un problème mathématique totalement indéterminé. Il est possible d'avoir des algorithmes plus ou moins performants (et aussi plus ou moins rapides ou lents), mais en aucun cas le résultat sera parfait ! Pourquoi est-ce impossible ? Si on se réfère aux principes de la gestion des couleurs [[http://rawpedia.rawtherapee.com/Color_Management_addon/fr#Balance_des_blancs]], il est nécessaire de connaitre à la fois l'objet coloré, l'illuminant et l'observateur. Il y a au moins 2 familles d'inconnues. De plus l'environnement de prise de vue n'est pas connu et influe sur la perception (CIECAM) ainsi que l'environnement de traitement et de visualisation. Donc, mission quasi impossible !&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'objectif du module '''&amp;quot;White balance&amp;quot; est de tester les algorithmes''', au total il y en a 7 et le double (au moins) si on prend en compte le &amp;quot;gamma sRGB&amp;quot;. En effet pour contourner les obstacles d'il y a 5 ans, j'ai utilisé au lieu de l'image avant demosaic, l'image juste après demosaic, sur laquelle on peut ou non appliquer le &amp;quot;gamma sRGB&amp;quot;, pour se retrouver dans les mêmes conditions qu'en usage normal (sinon bien sûr sans &amp;quot;White Balance&amp;quot; et sans profil &amp;quot;ICC ou DCP&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
L'idéal est de tester sur de nombreuses images les divers algorithmes &amp;quot;auto&amp;quot; avec un objectif : quel(s) algorithme(s) retenir et implanter en mode &amp;quot;full image&amp;quot; (peut être 1 ou 2 en plus de l'actuel qu'il faut garder pour compatibilité).&lt;br /&gt;
&lt;br /&gt;
====White balance contrôle local====&lt;br /&gt;
Le contrôle local est actuellement limité à 1 spot, mais pas de difficultés si les utilisateurs le souhaitent d’accroitre...En attendant les évolutions de &amp;quot;locallab&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Bien sûr il me sera dit &amp;quot;cela ne fonctionne pas&amp;quot;, ou &amp;quot;on ne se raccorde pas avec le 'preview'&amp;quot;. Cela fonctionne ! Et il est plus qu'évident que atteindre le preview est par définition quasi impossible... (différences ombres , soleil, illuminants différents, etc.) en dehors de la pertinence de l'algorithme.&lt;br /&gt;
&lt;br /&gt;
Vous disposez de 3 sliders : temperature, tint, blue/red equalizer&lt;br /&gt;
&lt;br /&gt;
== Quels défis à résoudre? ==&lt;br /&gt;
Plusieurs problèmes généraux sont à résoudre afin d'obtenir un fonctionnement fluide :&lt;br /&gt;
* permettre un nombre quasi illimité de RT-spot (spot de contrôles);&lt;br /&gt;
* adapter les algorithmes locaux aux problèmes d'échelle, car beaucoup d'algorithmes tiennent compte de la taille de l'image - donc de la zone traitée. Cet aspect est fondamental, notamment avec les courbes qui agissent sur toute l'image;&lt;br /&gt;
* minimiser l'occupation mémoire et les temps de traitement en sortie JPG et TIF;&lt;br /&gt;
* permettre des mises à jour logicielles faciles en cas d’évolution des algorithmes ou d'évolution du nombre de méthodes ;&lt;br /&gt;
* optimiser les écarts entre &amp;quot;preview&amp;quot; et sortie JPG / TIF; &lt;br /&gt;
* etc.&lt;br /&gt;
&lt;br /&gt;
Pour chaque RT-spot :&lt;br /&gt;
* permettre selon le cas, une action dans la zone sélectionnée ou à l'extérieur de la zone sélectionnée;&lt;br /&gt;
* permettre selon le cas une détection de forme pour délimiter l'action;&lt;br /&gt;
* assurer une transition entre le cœur de la zone traitée et le reste de l'image;&lt;br /&gt;
* etc.&lt;br /&gt;
&lt;br /&gt;
Actuellement, les RT-spot (spot de contrôles) sont opérationnels, pour le mode Lab, et pour les méthodes suivantes:&lt;br /&gt;
# Color and light : lightness, chrominance, contraste en mode normal avec quatre courbes L=f(L), L=f(H), C=f(C), H=f(H) et inverse ;&lt;br /&gt;
# Exposure : en mode normal&lt;br /&gt;
# Vibrance : en mode normal&lt;br /&gt;
# Blur and Noise : en mode normal et inverse;&lt;br /&gt;
# Retinex : en mode normal et inverse, maintenant avec gestion de la courbe &amp;quot;transmission gain&amp;quot;;&lt;br /&gt;
# Sharpening : en mode normal et inverse;&lt;br /&gt;
# Contrast By Detail Levels : en mode normal;&lt;br /&gt;
# Denoise : en mode normal.&lt;br /&gt;
&lt;br /&gt;
== Principes généraux ==&lt;br /&gt;
===L'Objet RT-spot===&lt;br /&gt;
Comme je l'ai évoqué, le système utilisé est proche de celui mis au point par Nik Software, avec de grandes différences :&lt;br /&gt;
* chaque RT-spot, peut être considéré comme un objet qui comporte plusieurs champ - à ce jour environ 70, constitués de curseurs, courbes;&lt;br /&gt;
* chaque champ, regroupé en paquets  peut être ou non activé, et peut avoir des valeurs variables selon sa nature ;&lt;br /&gt;
* les paquets sont des ensembles cohérents pour l'utilisateur : color &amp;amp; light, exposure, contrast, vibrance, blurr, retinex, sharpening, tone-mapping, contrast by detail level, denoise ;&lt;br /&gt;
* le nombre de &amp;quot;RT-spots objets&amp;quot; peut varier de 2 à 500 ;&lt;br /&gt;
* les données des &amp;quot;RT-spots objets&amp;quot; sont stockées dans un fichier texte &amp;quot;mip&amp;quot;;&lt;br /&gt;
* les &amp;quot;RT-spots objets&amp;quot; sont gérés - création, modification, suivi - dans une boucle &amp;quot;for&amp;quot;;&lt;br /&gt;
* il n'y a pas de duplication de code.&lt;br /&gt;
&lt;br /&gt;
===Le découpage en quatre zones - l’aperçu de la zone RT-spot===&lt;br /&gt;
Lorsque l’utilisateur sélectionne un RT-spot (spot de contrôle),l’image à l’écran montre:&lt;br /&gt;
* un centre, constitué d'un cercle dont on peut faire varier : a) le diamètre, b) la position avec la souris ou les curseurs;&lt;br /&gt;
* quatre lignes horizontales ou verticales dont on peut faire varier les positions avec la souris ou les curseurs.&lt;br /&gt;
* si vous sélectionnez en &amp;quot;Preferences&amp;quot; / &amp;quot;General&amp;quot; / &amp;quot;Local adjustements&amp;quot;, en cochant la case &amp;quot;Show spot delimiters&amp;quot;, vous obtiendrez une approximation de la zone concernée par le spot et ses réglages. Attention, je ne suis pas arrivé à un travail propre avec la fonction &amp;quot;arc / ellipse / scale&amp;quot; de la bibliothèque graphique Cairo; j'ai donc opté pour chaque &amp;quot;quart&amp;quot; à une pseudo ellipse obtenue par 3 courbes de Bézier se raccordant entre elles. Dans la majorité des cas l'approximation est satisfaisante...Pour permettre une sélection plus facile j'ai été amené à accroître la taille des 4 lignes horizontales et verticales qui sélectionnent la taille du spot (les courbes de Bézier sont inactives!).&lt;br /&gt;
&lt;br /&gt;
On aboutit à 4 zones, dont on ne peut faire varier l'orientation (angle d'inclinaison obligatoirement à zéro).&lt;br /&gt;
Ces 4 zones ont chacun de leurs sommets reliés par une ellipse imaginaire. &lt;br /&gt;
&lt;br /&gt;
Il est possible de pointer les limites des zones en dehors de la zone &amp;quot;preview&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
A terme, il doit être possible, même si l'utilité me semble discutable du fait de l'algorithme de détection de forme, de remplacer l'ellipse, par une courbe tracée à l'aide de la souris, à condition que la transformée homothétique de la courbe n'ait pas d'intersection avec la courbe originale. Cette &amp;quot;amélioration&amp;quot; intellectuellement satisfaisante, ne devrait être que d'un apport négligeable - dans le cas des U-points. Néanmoins il sera toujours possible de faire coexister les actuels U-points avec des contrôles par&amp;quot;lasso&amp;quot; de type Photoshop (c).&lt;br /&gt;
&lt;br /&gt;
===Les 2 types de RT-spot=== &lt;br /&gt;
Deux types de RT-spot sont proposés:&lt;br /&gt;
* Normal: chaque nouveau spot prend en compte les réglages des précédents - si bien sûr ils sont dans la zone d'action commune - on peut parler d'action récursive.&lt;br /&gt;
* Excluding : chaque nouveau spot réinitialise, l'image à partir des données originales, mais garde pour les calculs les références de l'image modifiée par les autres RT-spots.&lt;br /&gt;
&lt;br /&gt;
Dans les deux cas, vous avez accès à la quasi totalité des réglages : Color and Light, CBDL, Blur, etc.&lt;br /&gt;
&lt;br /&gt;
====Commentaires sur le &amp;quot;Excluding spot&amp;quot;:====&lt;br /&gt;
* il est dans le principe assez similaire au &amp;quot;Contre point&amp;quot; de Capture NX2(c) et permet de défaire des actions trop invasives par exemple une &amp;quot;bavure&amp;quot; non désirée. Ce défaut est lié - lorsqu'il se produit - à la trop grande proximité des teintes entre les zones - celle où on désire l'action et celle où on ne le souhaite pas.&lt;br /&gt;
* l'algorithme que j'ai utilisé est très proche de ceux présents jusqu'ici dans &amp;quot;locallab&amp;quot;, il est fondé sur les différences de couleurs. Il n'est pas &amp;quot;parfait&amp;quot; mais devrait satisfaire 70% des cas.&lt;br /&gt;
* j'ai préparé - sans garantie que cela fonctionne un jour - un complément pour mieux discriminer les zones, en s'appuyant sur la transformée de Sobel-Canny. La transformée est en place - non accessible à l'utilisateur - mais j'essaie de mettre en place un algorithme pas trop gourmand en temps de traitement... et bien sûr efficace.&lt;br /&gt;
&lt;br /&gt;
====Comment se servir de &amp;quot;Excluding spot&amp;quot; - limitations :====&lt;br /&gt;
# il suffit de placer le nouveau spot sur la zone à exclure&lt;br /&gt;
# choisir dans le menu &amp;quot;Settings&amp;quot;, Spot method = &amp;quot;Excluding spot&amp;quot;&lt;br /&gt;
# Puis régler &amp;quot;Scope&amp;quot;, &amp;quot;Transition&amp;quot; et &amp;quot;Spot size&amp;quot; ainsi bien sûr que 4 limiteurs de zone, pour obtenir les effets désirés. Vous pouvez utiliser des réglages complémentaires comme par exemple &amp;quot;Color and Light&amp;quot;...&lt;br /&gt;
Le système s’appuie sur l'image en cours et calcule les &amp;quot;références&amp;quot; (hue, chroma, luma) à partir de cette image (voir ci-après). En conséquences, si le fond est noir aucune retouche sera possible (ceci est possible en mode inverse &amp;quot;Color and light&amp;quot; lorsqu'on cherche à créer un cadre noir).&lt;br /&gt;
Dans quelque cas, en mode &amp;quot;inverse&amp;quot; le fonctionnement pourra être capricieux et amener des différences entre &amp;quot;preview&amp;quot; et sortie TIFF JPG. Dans ce cas accroitre &amp;quot;Scope&amp;quot; pour le &amp;quot;Excluding spot&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Les références teinte, chroma, luminance et le principe de l'algorithme en mode &amp;quot;normal&amp;quot;===&lt;br /&gt;
Afin de mettre en œuvre un algorithme performant de détection de forme :&lt;br /&gt;
* la zone du cercle central, sert de référence. En fonction du diamètre choisi par l'utilisateur, le système calcule, la moyenne de la teinte (hue), de la chroma, et de la luminance.&lt;br /&gt;
* le choix du diamètre de la zone centrale dépend de l'usage. Par exemple pour un feuillage, l'utilisateur aura intérêt à choisir une valeur faible afin de ne sélectionner que le vert du feuillage; à l'inverse pour la peau l'utilisateur aura intérêt  à accroître le diamètre afin d'éviter les prises en compte de données parasites (bruit, cils, etc.).&lt;br /&gt;
* pour chaque quart, et en fonction du curseur &amp;quot;scope&amp;quot;, le système prend en compte :&lt;br /&gt;
# en premier lieu de l'écart de teinte entre la zone centrale et le pixel courant ;&lt;br /&gt;
# puis, un algorithme complexe, s'appuyant sur la notion de deltaE (différence perçue entre 2 couleurs prenant en compte, la teinte, la chroma et la luminance), atténue l'action en fonction de l'écart entre la zone centrale et le pixel courant.&lt;br /&gt;
# la modification d'action utilise soit une loi linéaire, soit une loi parabolique selon le cas.&lt;br /&gt;
&lt;br /&gt;
Ceci va permettre de différencier l'action selon les critères énoncés ci-dessus, comme par exemple, si le cercle central se trouve dans un feuillage, de limiter l'action à l'ensemble du feuillage sans toucher à l'arrière plan (ce qui est impossible avec un lasso). De plus si un autre feuillage se situe dans la zone couverte, celui-ci sera également concernés par la modification.&lt;br /&gt;
&lt;br /&gt;
* l'action sur le curseur transition va permettre de faire varier l'action : si le curseur est réglé sur 50, la moitié (linéaire) de la zone concernée verra une application à 100% de l'effet, puis une transition agira régressivement jusqu'aux limites de la zone.&lt;br /&gt;
* si on accroît la valeur de &amp;quot;scope&amp;quot;, progressivement l’ensemble de la zone sélectionnée est prise en compte quelque soit la couleur, la chroma et la luminance. &lt;br /&gt;
* si on réduit la valeur de &amp;quot;scope&amp;quot;,l'action se limitera aux pixels très proches (en termes de deltaE) de la zone de référence.&lt;br /&gt;
&lt;br /&gt;
L'algorithme de détection de forme est opérationnel en mode &amp;quot;normal&amp;quot; sauf pour certains modules (denoise) - son implantation en mode inverse n'a pas de sens.&lt;br /&gt;
&lt;br /&gt;
Cet algorithme va avoir ses performances accrues, si l'utilisateur choisit : &amp;quot;Quality Enhanced&amp;quot; ou &amp;quot;Qualty enhanced + chroma denoise&amp;quot;. Ce second choix apporte une très légère réduction du bruit de chroma afin de supprimer les artefacts possibles liés à l'utilisation de &amp;quot;enhanced&amp;quot; (à noter dans le cas + chroma denoise, un accroissement des besoins en mémoire et du temps de traitement).&lt;br /&gt;
&lt;br /&gt;
L'algorithme utilise toutes ses capacités, si les valeurs de &amp;quot;scope&amp;quot; sont inférieures à 20.&lt;br /&gt;
&lt;br /&gt;
===Pourquoi pas d'autres algorithmes? ===&lt;br /&gt;
Remarque : il doit être possible de programmer d'autres algorithmes de détection de forme que celui ci-dessus fondé sur les différences de deltaE. &lt;br /&gt;
&lt;br /&gt;
* Par exemple les algorithmes de détection de bords (edge) tels que &amp;quot;Canny&amp;quot; ou &amp;quot;Sobel&amp;quot;;&lt;br /&gt;
* Ou encore le principe de décomposition en ondelettes.&lt;br /&gt;
Mais dans ces 2 cas tout reste à faire !&lt;br /&gt;
&lt;br /&gt;
===Le fonctionnement en mode inverse===&lt;br /&gt;
Lorsqu'il est proposé, le fonctionnement en mode inverse est extrêmement simplifié, seul le curseur &amp;quot;transition&amp;quot; permet de moduler l'action.&lt;br /&gt;
&lt;br /&gt;
A partir de fin octobre 2017, j'ai mis au point une autre manière de concevoir le mode &amp;quot;inverse&amp;quot;. Cette manière est limitée à l'outil &amp;quot;Blur and Noise&amp;quot; (voir ce paragraphe)&lt;br /&gt;
&lt;br /&gt;
===Nombre maximum de RT-spot (spot de contrôle)===&lt;br /&gt;
Par défaut le nombre de RT-spot est de 8.&lt;br /&gt;
Vous pouvez choisir n'importe quelle valeur entre 2 et 499. Pour cela il suffit de changer la variable Nspot dans le fichier &amp;quot;option&amp;quot;; par exemple Nspot=12.&lt;br /&gt;
Il est indispensable de relancer Rawtherapee après cette modification.&lt;br /&gt;
&lt;br /&gt;
===L'algorithme 'super'===&lt;br /&gt;
La clef du &amp;quot;succès&amp;quot; (si on peut utiliser ce terme) tient à l'algorithme présent depuis fin janvier 2017. je vais l'expliciter de manière simplifiée :&lt;br /&gt;
# pour la partie des données concernées par la zone sélectionnée, on applique une fonction courbe &amp;quot;traditionnelle&amp;quot; ou un curseur classique, ou la fonction de transfert normale (Retinex, Tone mapping, CBDL, Vibrance, ...);&lt;br /&gt;
# puis on réalise une conversion de la LUT ou de la fonction de transfert , en un équivalent &amp;quot;slider&amp;quot;, en séparant les valeurs positives et négatives, afin d'avoir une représentation de la fonction comme une multitude de &amp;quot;sliders&amp;quot; (autant qu'il y a de pixels concernés) dans l'intervalle -100, 0, +100&lt;br /&gt;
# on passe ces données à la fonction de reconnaissance de forme - celle des 4 zones. On détecte pour chaque pixel l'écart de teinte, chroma et luma par rapport à la référence. On établit des équations de variations linéaire selon le cas de la luminance (L = f(L)) ou de la chroma (C=f(C) ou des fonctions de transfert).&lt;br /&gt;
# puis on applique diverses corrections pour tenir compte de l'environnement, ciel, peau,...&lt;br /&gt;
# enfin, on applique une correction (avec seuil et itérations)pour ne pas corriger (ou le faire faiblement selon le choix de l'utilisateur), les tons gris ou neutres qui sont dans la même teinte que la référence (mais avec une chroma faible).&lt;br /&gt;
# ces paramètres sont ensuite pondérés en fonction, de la forme (ellipse) et de la zone de transition.&lt;br /&gt;
# bien sûr les réglages des paramètres qualité &amp;quot;Global quality&amp;quot;, ont leur importance, notamment dans les images légèrement bruitées - le bruit chromatique est considéré par l'algorithme comme de la même couleur que le spot. Il faut donc avoir la possibilité de le supprimer, d'où la sélection &amp;quot;enhanced + chroma denoise&amp;quot; (il est possible que ce réglage soit insuffisant, agir en conséquence sur &amp;quot;Denoise local&amp;quot; si nécessaire).&lt;br /&gt;
&lt;br /&gt;
Cet algorithme nouveau ('super') semble généralement fonctionner, mais dans le cas où le spot est sur une zone gris - neutre ou l'action sur des zones à faible gradient, l'algorithme peut être pris en défaut, dans ce cas utiliser l'ancien (quand c'est possible !!), car pour Retinex, Tone Mapping, CBDL je n'ai pas offert ce choix par souci de simplification)&lt;br /&gt;
&lt;br /&gt;
===Réduction des artefacts et l'algorithme &amp;quot;Global quality&amp;quot;===&lt;br /&gt;
Par défaut, &amp;quot;Global quality&amp;quot; est à &amp;quot;Enhanced + chroma denoise&amp;quot;. Certes cela augmente les temps de traitements, mais globalement c'est préférable. Vous pouvez, si vous trouvez les temps de rafraichissement long, choisir &amp;quot;enhance&amp;quot; ou &amp;quot;standard&amp;quot; et examiner l'image...&lt;br /&gt;
* 2 curseurs permettent de réduire les artefacts et améliorer le rendu de l'algorithme. Ils agissent en fonction de la chroma, dans les tons gris neutres. Pour désactiver complètement l'effet il suffit de mettre &amp;quot;iterations = 0&amp;quot;. Ces curseurs permettent, d'une part de réduire les artefacts et,  d'autre part d'agir sur le rendu de l'image. L'action est possible pour &amp;quot;Color Light&amp;quot;, &amp;quot;Exposure&amp;quot;, &amp;quot;Retinex&amp;quot;, &amp;quot;Vibrance&amp;quot;, &amp;quot;Tone Mapping&amp;quot; et &amp;quot;Contrast by details levels&amp;quot;.&lt;br /&gt;
* lorsque les images sont bruitées, même légèrement (beaucoup d’images sont bruitées sans que cela soit gênant par exemple les ciels, les nuages,...), les algorithmes sont &amp;quot;trompés&amp;quot;, ne pas hésiter à laisser activé &amp;quot;Global quality = enhanced + chroma denoise&amp;quot; et (quelquefois) activer &amp;quot;denoise local&amp;quot; et agir très légèrement sur les curseurs (y compris luminance). &lt;br /&gt;
* dans certaines circonstances, par exemple avec Tone-mapping, le système de réduction d'artefacts peut générer des artefacts. Dans ce cas, mettre le slider &amp;quot;iterations&amp;quot; à 0.&lt;br /&gt;
&lt;br /&gt;
Vous pouvez choisir la valeur par défaut de &amp;quot;Global Quality&amp;quot;, par exemple si vos images sont très peu bruitées, et ainsi réduire notablement les temps de traitement.&lt;br /&gt;
Pour cela, aller dans &amp;quot;Preferences&amp;quot;, &amp;quot;Performance and Quality&amp;quot;, &amp;quot;Local adjustements&amp;quot; et choisir entre Les 3 propositions. C'est ce choix qui sera proposé par défaut à l'utilisateur pour chaque nouveau &amp;quot;Spot&amp;quot;, bien sûr il est possible ensuite de modifier ce choix, en sélectionnant la combo-box &amp;quot;Global Quality&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Avoid color shift===&lt;br /&gt;
Cette case à cocher vise deux objectifs :&lt;br /&gt;
* mettre les couleurs dans le gamut de l'espace de travail courant (working profile) en utilisant une colorimétrie relative ;&lt;br /&gt;
* ajuster les couleurs à l'aide d'une correction &amp;quot;Munsell&amp;quot; - notamment les rouges-orangés et les bleus-pourpres, lorsque la saturation dans le domaine L*a*b* a évolué notablement.&lt;br /&gt;
&lt;br /&gt;
===Les fichiers *.mip - les principes de l’algorithme multipoints=== &lt;br /&gt;
Afin de permettre le fonctionnement - enregistrement des valeurs pour chaque spot de contrôle - un fichier de type texte, assez proche des fichiers pp3 est enregistré à deux endroits possibles :&lt;br /&gt;
* à côté du fichier à traiter. Si par exemple vous traitez le fichier ASC4509.NEF, un fichier ASC4509.NEF.mip sera enregistré dans le même dossier. Si vous choisissez cet emplacement, vous pourrez ouvrir plusieurs sessions pour un même fichier image, si celui-ci est présent dans des dossiers différents. Par contre, le nom des dossiers et du &amp;quot;path&amp;quot; doit obligatoirement n'avoir que des caractères ASCII...sinon plantage. &lt;br /&gt;
* dans le dossier &amp;quot;mip&amp;quot;, à l'intérieur du dossier &amp;quot;cache&amp;quot; (via un &amp;quot;hash number MD5&amp;quot; qui identifie le fichier). Valeur par défaut. Si vous choisissez cet emplacement, si le fichier image est présent dans plusieurs dossiers, il y aura plusieurs fichiers mip. Cette option permet d'utiliser des dossiers et &amp;quot;path&amp;quot; avec des caractères NON ASCII.&lt;br /&gt;
* le choix entre ces emplacements est possible à partir de : Preferences / Image processing / Mip Profiles&lt;br /&gt;
 &lt;br /&gt;
Ce fichier mip contient les données qui seront ensuite passées au programme, via d'une part les processus de type &amp;quot;procparams&amp;quot; et d'autre part des LUT qui permettent le fonctionnement en mode zoom.&lt;br /&gt;
Lors de la mise à jour d'une nouvelle version, il pourra dans certains cas être demandé d'effacer les fichiers *.mip (voire le cache)  afin d'éviter un crash. Pour cela vous pouvez aller dans &amp;quot;Preferences&amp;quot; / &amp;quot;Files browser&amp;quot;, puis &amp;quot;Clear mip&amp;quot; et / ou &amp;quot;clear pp3&amp;quot; - si bien sûr vous avez positionné &amp;quot;mip&amp;quot; et &amp;quot;pp3&amp;quot; dans le cache, sinon il faudra exécuter cette opération manuellement dans le dossier courant. La présence d'anciennes versions de fichiers &amp;quot;mip&amp;quot; ou de &amp;quot;pp3&amp;quot; peut amener de l'instabilité voire un crash du système. &lt;br /&gt;
&lt;br /&gt;
====Architecture du système====&lt;br /&gt;
Lorsque je me suis &amp;quot;aventuré&amp;quot; vers la possibilité d'un système multipoints sans calques, sans masques,...il était obligatoire de refuser de dupliquer le code. Comment envisager par exemple pour 10 spot de contrôles, 10 codes GUI, et autant de code dans Rtengine.&lt;br /&gt;
Après réflexion, l’idée est venue d'avoir un fichier mis à jour en temps réel - c'est à dire qui suit les modifications faites par l'utilisateur - de l’historique des actions / modifications.&lt;br /&gt;
&lt;br /&gt;
Bien sûr, les variables utilisées par Rawtherapee, au niveau de l'interface GUI, et par la suite dans l'ensemble du code via &amp;quot;params&amp;quot;, sont de type divers:&lt;br /&gt;
* numériques : entier, float,  double,...&lt;br /&gt;
* booléenne&lt;br /&gt;
* choix (menus pour &amp;quot;méthodes&amp;quot;) de type string&lt;br /&gt;
* courbes via des &amp;quot;vectors&amp;quot; de type double a dimension dynamique.&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
====Conversion des données====&lt;br /&gt;
La première étape - afin de simplifier ensuite la gestion des données - est de convertir toutes ces données en entiers. Dans quelques cas cela peut aboutir à une très légère perte de précision, qui de mon point de vue est tout à fait négligeable.&lt;br /&gt;
*Cette opération est très simple pour les valeurs numériques, même si elle peut aboutir dans certains cas (la teinte  - Hue - s'exprime en radians dans l’intervalle -Pi + Pi) par une double transformation &amp;quot;float * 100 et / 100&amp;quot; pour garder la précision.&lt;br /&gt;
*Elle est logique pour les opérations booléennes et les méthodes.&lt;br /&gt;
*Par contre elle s'est avérée complexe pour les courbes. Les valeurs à stocker dans le fichier texte sont de type vector&amp;lt;double&amp;gt; soit un tableau dynamique de valeurs numériques. Probablement il doit y avoir un moyen &amp;quot;plus simple&amp;quot; en utilisant les fonctions qui sont utilisées dans &amp;quot;Procparams&amp;quot;, mais je ne suis pas arrivé à les mettre en œuvre. J'ai contourné l'obstacle en :&lt;br /&gt;
#transformant les valeurs doubles en entier avec 3 chiffres significatifs - ce qui est largement suffisant&lt;br /&gt;
#puis en convertissant le &amp;quot;vector&amp;quot; en une chaine de caractère de longueur variable&lt;br /&gt;
#la lecture et l'écriture de cette chaine et sa conversion en &amp;quot;vector&amp;quot; se faisant dynamiquement par une fonction appropriée (&amp;quot;strcurv_data&amp;quot;). A noter que cette fonction permet de modifier des courbes jusqu'à une limite de 16 points d'inflexion (Courbe de Beziers) pour la courbe plate, et 32 pour la diagonale, ce qui devrait être suffisant. Si c'était insuffisant (??) il est possible (via une perte de compatibilité) d'accroître ce nombre.&lt;br /&gt;
&lt;br /&gt;
====Quelques éléments sur les courbes====&lt;br /&gt;
L'implémentation des courbes a été complexe, au delà de ce qui est écrit ci-dessus, notamment :&lt;br /&gt;
# chaque courbe doit obligatoirement avoir une fonction reset - resize() à chaque itération;&lt;br /&gt;
# ce qui implique des curiosités au niveau de leur description, par exemple la courbe diagonale est initialisée avec plusieurs points, alors qu'elle a l'air &amp;quot;vide&amp;quot;. C'est indispensable au bon fonctionnement. Mais ceci a pour conséquence que cette courbe est toujours ouverte / active. Donc cela implique si on veut éviter des consommations de temps en mode &amp;quot;preview&amp;quot; que l'utilisateur &amp;quot;active&amp;quot; la courbe en activant la combobox &amp;quot;curves&amp;quot;. Cette même activation est aussi nécessaire pour les courbes L=f(H) et C=f(C). Bien sûr, on se serait tenté de penser qu'il suffit d'activer le mode &amp;quot;enabled&amp;quot; de la fonction &amp;quot;courbes&amp;quot; (linéaire), mais après de nombreux essais cette démarche est infructueuse!&lt;br /&gt;
# tout au long des procédures, il est obligatoire de mettre &amp;quot;clear&amp;quot; chaque valeur de &amp;quot;params&amp;quot; pour les courbes, chaque LUT, pour chaque itération et ensuite via &amp;quot;vector&amp;quot; de réattribuer les bonnes valeurs courantes à &amp;quot;params courbe&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
====Stockage et utilisation dynamique des données====&lt;br /&gt;
Une fois les données converties :&lt;br /&gt;
* elles sont stockées dans un fichier texte&lt;br /&gt;
* chacune est référencée dans un tableau dynamique à deux dimensions : &lt;br /&gt;
# dataspot[x][y], pour les valeurs numériques, booléenne et les méthodes,   où 'x' représente l'indice représentatif de la variable, par exemple '9' correspond à 'Lightness', et 'y' représente le RT-spot (spot de contrôle) courant. La valeur '0' représente la valeur courante en cours d'utilisation (celle stockée dans 'params&amp;quot;). &lt;br /&gt;
# retistr[y], llstr[y], lhstr[y], ccstr[y], hhstr[y], skinstr[y], pthstr[y], exstr[y] pour les variables de type &amp;quot;curve&amp;quot; (aujourd'hui il n'y a que 8 variables celle utilisée dans &amp;quot;Retinex&amp;quot; local, et celles dans &amp;quot;Color and light&amp;quot; (L=f(L), C=f(C), L=f(H), H=F(H))et  &amp;quot;vibrance&amp;quot; et &amp;quot;exposure&amp;quot;,  mais il est assez facile d'en ajouter), avec 'y' comme ci-dessus.&lt;br /&gt;
&lt;br /&gt;
Ce stockage et utilisation - nous reviendrons plus loin sur l'algorithme lecture / écriture dynamique - convient aisément pour le fichier Improccoordinator.cc (support de la gestion courante - Preview) et Simpleprocess.cc (sortie TIF / JPG), mais ne peut convenir, pour Dcrop.cc et la vision partielle de l'image (les fameux pipeline de Rawtherapee).&lt;br /&gt;
&lt;br /&gt;
Pour ce cas (zoom - Preview) il a fallu imaginer autre chose, qui assure en temps réel la synchronisation des modifications. J'ai utilisé des LUT, dans le cas actuel, à chaque donnée référencée dans les tableaux ci dessus est associé une LUTi(z), avec z=500 entrées possibles (500 correspond à la limite informatique du nombre de RT-spot (spots de contrôles)...qu'on peut très facilement accroitre ou réduire). 'z' pour les LUTi correspond à 'y' pour dataspot. Une LUTi avec 25000 (arbitraire) entrées est utilisée  pour &amp;quot;retistr&amp;quot;, &amp;quot;llstr&amp;quot;, &amp;quot;lhstr&amp;quot;, &amp;quot;ccstr&amp;quot;, &amp;quot;hhstr&amp;quot;, &amp;quot;skinstr&amp;quot;, &amp;quot;pthstr&amp;quot;, &amp;quot;exstr&amp;quot; pour garder en mémoire (sous forme d'un entier) chaque valeur du 'Vector' de la courbe (il peut y en avoir jusque 69).&lt;br /&gt;
 &lt;br /&gt;
Au cours du traitement, des échanges sont réalisés entre: params, les tableaux dynamiques et les LUTi. Les valeurs utilisées par Dcrop.cc sont liées dynamiquement aux tableaux dynamiques par parent-&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
====Processus d'échanges et stockage des données dynamiques ====&lt;br /&gt;
Sans entrer dans une description fastidieuse, je resterais aux principes généraux :&lt;br /&gt;
# lecture du fichier &amp;quot;mip&amp;quot; pour lire la version et orienter  les mises à jour&lt;br /&gt;
# première écriture du fichier &amp;quot;mip&amp;quot; s'il n'existe pas&lt;br /&gt;
# stockage des données dans les LUTi et les tableaux dynamiques à partir des valeurs stockées dans &amp;quot;Params&amp;quot; (valeurs index 0)&lt;br /&gt;
# première mise à jour interactive avec le GUI via une fonction de transfert entre Rtengine et locallab.cc (aloListener-&amp;gt;localretChanged). Cette fonction fait partie des 3 nécessaires pour obtenir un fonctionnement correct.&lt;br /&gt;
# lecture du fichier texte &amp;quot;mip&amp;quot; et stockage des données dans les tableaux dynamiques (valeurs index ==&amp;gt; y) - selon le nombre de RT-spot (spots de contrôle)&lt;br /&gt;
# Création d'une boucle - selon le nombre de RT-spot (spots de contrôle)- où à partir des valeurs stockées dans les variables tableaux dynamique, les LUTi (nécessaires à Dcrop) et les valeurs de Params sont actualisées.&lt;br /&gt;
# Appel de la fonction &amp;quot;Lab_local&amp;quot; qui contient les algorithmes de contrôle de chaque RT-spot (luminance, Sharp, retinex, denoise, etc.)  &lt;br /&gt;
# deuxième mise à jour interactive avec le GUI via une autre fonction de transfert entre Rtengine et locallab.cc &lt;br /&gt;
# puis traitement du RT-spot (spot de contrôle) courant, en récupérant les valeurs index (0) des tableaux dynamiques. Ces valeurs sont attribuées à : 1) params, 2) LUTi, 3) valeurs index en cours&lt;br /&gt;
# Appel de la fonction &amp;quot;Lab_local&amp;quot; pour le RT-spot courant.&lt;br /&gt;
# sauvegarde du fichier &amp;quot;mip&amp;quot;&lt;br /&gt;
&lt;br /&gt;
A noter que si l'utilisateur, modifie une courbe, amplitude ou nombre de points d'inflexion, une troisième mise à jour interactive est réalisée pour mettre en conformité l’ensemble des données en fonction des événements.&lt;br /&gt;
&lt;br /&gt;
====Quelques fantaisies incontournables====&lt;br /&gt;
Bien sûr, tout à l'air simple, mais le système ne fonctionne que, si et seulement si, toutes les données sont dynamiquement mises à jour.&lt;br /&gt;
&lt;br /&gt;
J'ai beaucoup essayé, tâtonné, pour aboutir à une solution qui fonctionne...certes curieuse; il y a probablement un moyen plus &amp;quot;informatique&amp;quot; de traiter cela, mais à ce stade, j'ai fait comme décrit ci-dessus et ci-après.&lt;br /&gt;
&lt;br /&gt;
Les 3 échanges entre Rtengine et le GUI se font notamment avec 3 variables qui ne servent à rien dans le programme - sinon à mettre à jour:&lt;br /&gt;
# &amp;quot;anbspot&amp;quot; qui prend les valeurs forcées 0 ou 1&lt;br /&gt;
# &amp;quot;cTgainshaperab&amp;quot; (curve), dont je fais osciller une valeur entre 0.70 et 0.90&lt;br /&gt;
# &amp;quot;retrab&amp;quot; qui oscille autour de 500.&lt;br /&gt;
&lt;br /&gt;
J'ai ajouté 3 variables (sous forme de &amp;quot;sliders&amp;quot;) - hueref, chromaref, lumaref, totalement invisibles à l'utilisateur, mais qui servent à rafraichir le système en temps réel, pour permettre la bonne prise en compte des valeurs &amp;quot;spot&amp;quot; de référence.  &lt;br /&gt;
&lt;br /&gt;
Les appels aux changements de ces 3 variables amènent la stabilité au système et une mise à jour en temps réel.&lt;br /&gt;
Il ne devrait pas être nécessaire d’accroitre le nombre de ces variables &amp;quot;fantaisistes&amp;quot; &lt;br /&gt;
&lt;br /&gt;
De plus j'ai été amené à empiriquement mettre des temporisations, pour laisser le temps au temps... C'est notamment le cas pour la modification de la courbe par l’utilisateur (amplitude, nombre de points d'inflexion).&lt;br /&gt;
&lt;br /&gt;
Bien sûr ces variables  sont invisibles pour l'utilisateur, sinon dans l'historique !&lt;br /&gt;
&lt;br /&gt;
==Quelques particularités du mode local (par rapport à Lab adjustements)==&lt;br /&gt;
&lt;br /&gt;
Voici quelques informations qui peuvent intéresser l'utilisateur. Ces informations sont souvent des particularités du mode local&lt;br /&gt;
&lt;br /&gt;
===Color and Light===&lt;br /&gt;
*Les algorithmes utilisés pour la luminance et le contraste sont différents de ceux utilisés par &amp;quot;Lab adjustements&amp;quot;, ce qui peut amener quelques différences de rendu.&lt;br /&gt;
*L'algorithme de luminance est réalisé de telle manière que en dessous de -90 et jusque -100 pour &amp;quot;lightness&amp;quot;, il est possible d'accroître la &amp;quot;darkness&amp;quot; de l'image, pratiquement jusqu'à obtenir une valeur de luminance proche de 0. Si vous souhaitez accentuer cet effet, réduisez également la chominance et accroissez &amp;quot;scope&amp;quot;.&lt;br /&gt;
*Le mode inverse, peut servir pour l'essentiel, à réaliser des cadres dégradés. Dans ce cas, si vous sélectionnez -100 pour &amp;quot;lightness&amp;quot;, et réduisez la chrominance, la &amp;quot;bordure&amp;quot; sera noire.&lt;br /&gt;
* pour la luminance et le contraste (curseur), vous avez le  choix entre 2 algorithmes : le premier (par défaut) est très proche de ce qui était présent jusque là, le second activé par &amp;quot;Lightness Contrast super&amp;quot; est proche de celui utilisé pour les courbes &amp;quot;super&amp;quot;&lt;br /&gt;
* ne pas hésiter selon le cas, à activer &amp;quot;Global quality&amp;quot; = enhanced  et (défaut) enhanced + chroma denoise&amp;quot;&lt;br /&gt;
====Courbes====&lt;br /&gt;
*Une courbe L=f(L) et une C=f(C) permet de moduler la luminance ou la chrominance pour chaque RT-spot (spot de contrôle) en fonction de la luminance ou de la chrominance. &lt;br /&gt;
*Une courbe L=f(H) permet de moduler la luminance pour chaque RT-spot en fonction de la teinte. &lt;br /&gt;
*Une courbe H=f(H) permet de moduler la teinte pour chaque RT-spot en fonction de la teinte.&lt;br /&gt;
Pour les rendre actives, il est nécessaire d'activer la combobox &amp;quot;Curves type&amp;quot;.&lt;br /&gt;
* deux choix sont offerts : &lt;br /&gt;
** a) Normal : les courbes - notamment la plus complexe à gérer L=f(L) utilise un algorithme proche de celui utilisé avec les curseurs (mode Normal);&lt;br /&gt;
** b) Super : utilise un nouvel algorithme que je pense très performant (le résultat m'a même surpris à la première utilisation).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Attention, lorsque le spot est située dans une zone grise, ou des zones assez uniformes, les artefacts avec le nouvel algorithme (L=F(L) super, et Lightness Contrast super) peuvent être impossible à supprimer, dans ce cas privilégier l’algorithme &amp;quot;normal&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Exposure===&lt;br /&gt;
Ce module &amp;quot;ressemble&amp;quot; à celui en mode global RGB, mais :&lt;br /&gt;
* il fonctionne entièrement en mode L*a*b*, d'où des différences de rendu;&lt;br /&gt;
* il n'a pas les curseurs &amp;quot;lightness, chroma et contraste&amp;quot; dont les fonctions sont déjà présentes dans &amp;quot;Color and Light&amp;quot;&lt;br /&gt;
* il y a une seule courbe &amp;quot;contraste&amp;quot;, similaire à celle de L=F(L) présente dans &amp;quot;Color and Light&amp;quot;. Il est évident que le rendu de cette courbe est différent de &amp;quot;Tonecurve&amp;quot; qui agit en mode RGB. Vous pouvez si vous le souhaitez activer les 2 courbes L=f(L) dans &amp;quot;Color and Light&amp;quot; et &amp;quot;Exposure&amp;quot; &lt;br /&gt;
&lt;br /&gt;
===Vibrance===&lt;br /&gt;
Module similaire à celui du menu principal.&lt;br /&gt;
&lt;br /&gt;
===Blur and Noise===&lt;br /&gt;
Blur n'est actif que si Radius supérieur ou égal à 2.&lt;br /&gt;
&lt;br /&gt;
En réduisant notablement la valeur par défaut de &amp;quot;scope&amp;quot; et en agissant éventuellement sur &amp;quot;Luminance only&amp;quot; il est possible d'obtenir des flous différenciés selon la teinte.&lt;br /&gt;
&lt;br /&gt;
Vous disposez (octobre 2017), de 3 méthodes :&lt;br /&gt;
* &amp;quot;normal&amp;quot; : l'algorithme de détection de forme a été amélioré. Il se rapproche de celui utilisé dans les autres modules.&lt;br /&gt;
* &amp;quot;inverse&amp;quot; : algorithme simplifié, ne faisant pas intervenir &amp;quot;scope&amp;quot;. L'inversion est grossière et ne permet pas une séparation fine des zones à traiter / conserver.&lt;br /&gt;
* &amp;quot;symmetric&amp;quot; : ce nouvel algorithme utilise les mêmes processus que &amp;quot;normal&amp;quot; et par l'utilisation de &amp;quot;scope&amp;quot; l'utilisateur peut cibler plus précisément l'action. &lt;br /&gt;
&lt;br /&gt;
Attention:&lt;br /&gt;
* travailler en mode inverse, va flouter des zones importantes qui ne pourront pas être corrigées ensuite&lt;br /&gt;
* l'action de &amp;quot;scope&amp;quot; peut être déroutante dans certains cas : par exemple pour un portrait les yeux - différents de la peau - seront floutés si &amp;quot;scope&amp;quot; est trop faible.&lt;br /&gt;
&lt;br /&gt;
===Tone mapping===&lt;br /&gt;
Attention aux artefacts lorsque les aplats (ciels, zones grises...) sont d'une teinte similaire au spot de contrôle. Dans le cas d'artefacts, mettre le curseur &amp;quot;iterations&amp;quot; de &amp;quot;Reduce artefacts - improve algorithm&amp;quot; à zéro.&lt;br /&gt;
&lt;br /&gt;
===Retinex===&lt;br /&gt;
Le nombre de réglages est réduit, par rapport au mode standard. D'autre part, &amp;quot;Retinex local&amp;quot; agit en fin de processus contrairement au mode standard qui est au début du processus Raw.&lt;br /&gt;
Depuis la version mip 10002, la courbe &amp;quot;transmission gain&amp;quot; est spécifique à chaque RT-spot.&lt;br /&gt;
&lt;br /&gt;
===Sharpening===&lt;br /&gt;
Seul le mode &amp;quot;RL deconvolution&amp;quot; est proposé.&lt;br /&gt;
&lt;br /&gt;
===Contrast By Detail Levels===&lt;br /&gt;
* 5 niveaux au lieu de 6 pour le mode pleine image.&lt;br /&gt;
* pas de curseurs pour la gestion de la peau; le système utilisé par les RT-spot le remplace.&lt;br /&gt;
* ajout d'un curseur pour la chroma&lt;br /&gt;
* Attention aux artefacts lorsque les aplats (ciels, zones grises...) sont d'une teinte similaire au RT-spot. Dans le cas d'artefacts, mettre le curseur &amp;quot;iterations&amp;quot; de &amp;quot;Reduce artefacts - improve algorithm&amp;quot; à zéro.&lt;br /&gt;
&lt;br /&gt;
===Denoise===&lt;br /&gt;
* par rapport au mode pleine image, seul l'outil wavelet est utilisé: donc pas de fonction de Fourier, ni de medians&lt;br /&gt;
* moins de curseurs et de courbes&lt;br /&gt;
* par contre, vous pouvez différencier l'action sur la luminance et la chrominance en fonction de la grosseur du bruit - fine ou coarse.&lt;br /&gt;
&lt;br /&gt;
==Cas d'usage spécifique : réduction des défauts (capteur sale, yeux rouges, ...)==&lt;br /&gt;
Par conception &amp;quot;Locallab&amp;quot; n'a pas été conçu pour éliminer ces défauts. Néanmoins par effet de bord, certains défauts apparents et gênant en photographie peuvent être réduits voire supprimés. Ceci bien sûr n'est pas incompatible avec d'autres modules plus spécialisés incorporés ou non à &amp;quot;Locallab&amp;quot;...&lt;br /&gt;
Au moins 3 fonctions présentes, en adaptant l'usage, peuvent être utilisées, séparément ou ensemble :&lt;br /&gt;
* &amp;quot;Color and light&amp;quot; pour des défauts ponctuels ;&lt;br /&gt;
* &amp;quot;Contrast by detail level&amp;quot; pour des défauts répartis ;&lt;br /&gt;
* &amp;quot;Blur and Noise&amp;quot; en complément éventuel : attention cette action est assez destructrice - à utiliser avec modération.&lt;br /&gt;
&lt;br /&gt;
Vous pouvez agir soit:&lt;br /&gt;
* directement, cas général, sur le fichier &amp;quot;raw&amp;quot;, ou &amp;quot;TIF&amp;quot;, etc.&lt;br /&gt;
* soit sur le fichier flat-field si vous en avez élaboré un.&lt;br /&gt;
  &lt;br /&gt;
===Utilisation avec le module &amp;quot;Color and Light&amp;quot;===&lt;br /&gt;
* Activez &amp;quot;Color and Light&amp;quot;&lt;br /&gt;
*Vous pouvez utiliser l'équivalent d'une fonction &amp;quot;yeux rouges&amp;quot; en choisissant un encadrement assez serré de l’œil - sélecteur circulaire centré sur le rouge, délimiteurs de spot proches de l’œil - une valeur de scope réduite, puis agir sur réduction &amp;quot;lightness&amp;quot; -100, et réduction chrominance -100.&lt;br /&gt;
*De la même manière vous pouvez réduire les défaut du capteur de type &amp;quot;Spot IR&amp;quot;,  en choisissant un encadrement assez serré du défaut - sélecteur circulaire centré sur le défaut, délimiteurs de spot proches du défaut - puis agir sur &amp;quot;chrominance&amp;quot; en réduisant la valeur, agir éventuellement sur &amp;quot;scope&amp;quot; pour réduire l'étendue de l'action.&lt;br /&gt;
*Vous pouvez dans des cas simples, réduire les défauts de type &amp;quot;capteur encrassé&amp;quot; notamment lorsque celui-ci est gras. Ceci se traduit par des taches qui apparaissent sur les fonds unis. Pour cela choisissez un encadrement assez serré du défaut - sélecteur circulaire centré sur le défaut (adaptez la taille du spot) , délimiteurs de spot pas trop proches du défaut pour permettre une transition peu visible. Puis: a) réduisez &amp;quot;Transition&amp;quot; à des valeurs faibles; b) cochez &amp;quot;Lightness contrast super&amp;quot;; c) agissez sur &amp;quot;luminance&amp;quot; et éventuellement sur &amp;quot;chrominance&amp;quot; pour approcher le rendu de la zone polluée à celui de la zone saine; d) agir modérément sur &amp;quot;scope&amp;quot; pour moduler l'action souhaitée.&lt;br /&gt;
&lt;br /&gt;
===Utilisation avec le module &amp;quot;Contrast by detail levels&amp;quot;===&lt;br /&gt;
Dans le cas de capteur encrassé (de type &amp;quot;graisse&amp;quot;), et lorsque la zone est importante ou pour une série de petits défauts, Il peut être utile d'utiliser &amp;quot;Contrast by details levels&amp;quot; qui va agir comme un outil &amp;quot;wavelet&amp;quot; sur la luminance et aussi si nécessaire sur la chrominance. Dans ce cas: a) mettez le Spot de sélection sur un défaut prononcé (en adaptant sa taille si nécessaire); b) choisissez une zone de sélection large pour couvrir la majorité de la surface concernée par les défauts; c)Sélectionnez une valeur de transition assez importante; d) Activez &amp;quot;Contrast by detail levels&amp;quot; et agissez sur les niveaux 3 et 4 ou plus faibles en réduisant le contraste (valeurs inférieures à 100) et en agissant si nécessaire sur le curseur chroma.&lt;br /&gt;
&lt;br /&gt;
== Temps de traitement et utilisation de la mémoire ==&lt;br /&gt;
&lt;br /&gt;
Lorsqu'on utilise la sortie JPG ou TIF, et pour le mode &amp;quot;normal&amp;quot;, l'algorithme n'effectue les calculs que pour la zone délimitée. En ce sens les temps de traitement et l'occupation mémoire sont réduits.&lt;br /&gt;
Bien sûr le temps de traitement va dépendre du nombre de spots de contrôles, de leur taille, et du type de traitement.&lt;br /&gt;
&lt;br /&gt;
Si on exclue &amp;quot;Denoise&amp;quot; et &amp;quot;Sharp&amp;quot;, les temps de traitement sont de l'ordre de quelques dixièmes de seconde par spot de contrôle, et le besoin en mémoire de l'ordre de quelques centaines de M.&lt;br /&gt;
&lt;br /&gt;
Deux réglages agissent fortement sur les temps de traitement et le besoin en mémoire :&lt;br /&gt;
* denoise qui ajoute selon la taille du spot de contrôle de l'ordre de 1 seconde et 1 M de mémoire.&lt;br /&gt;
* quality enhanced and chroma denoise, qui ajoute environ selon le spot de contrôle de l'ordre de 0.5 secondes et 0.6 M.&lt;br /&gt;
&lt;br /&gt;
==Onglet Preferences==&lt;br /&gt;
J'ai regroupé ici, les réglages (repris par ailleurs sur cette page) accessibles depuis &amp;quot;Preferences&amp;quot;&lt;br /&gt;
* si vous sélectionnez en &amp;quot;Preferences&amp;quot; / &amp;quot;General&amp;quot; / &amp;quot;Local adjustements&amp;quot;, en cochant la case &amp;quot;Show spot delimiters&amp;quot;, vous obtiendrez une approximation de la zone concernée par le spot et ses réglages&lt;br /&gt;
* Vous pouvez choisir la valeur par défaut de &amp;quot;Global Quality&amp;quot;, par exemple si vos images sont très peu bruitées, et ainsi réduire notablement les temps de traitement.Pour cela, aller dans &amp;quot;Preferences&amp;quot;, &amp;quot;Performance and Quality&amp;quot;, &amp;quot;Local adjustements&amp;quot; et choisir entre Les 3 propositions. C'est ce choix qui sera proposé par défaut à l'utilisateur pour chaque nouveau &amp;quot;Spot&amp;quot;, bien sûr il est possible ensuite de modifier ce choix, en sélectionnant la combo-box &amp;quot;Global Quality&amp;quot;&lt;br /&gt;
* Fichiers &amp;quot;mip&amp;quot;: &lt;br /&gt;
**le choix de l'emplacement est possible à partir de : Preferences / Image processing / Mip Profiles&lt;br /&gt;
** effacement : aller dans &amp;quot;Preferences&amp;quot; / &amp;quot;Files browser&amp;quot;, puis &amp;quot;Clear mip&amp;quot; et / ou &amp;quot;clear pp3&amp;quot; - si bien sûr vous avez positionné &amp;quot;mip&amp;quot; et &amp;quot;pp3&amp;quot; dans le cache, sinon il faudra exécuter cette opération manuellement dans le dossier courant. La présence d'anciennes versions de fichiers &amp;quot;mip&amp;quot; ou de &amp;quot;pp3&amp;quot; peut amener de l'instabilité voire un crash du système.&lt;br /&gt;
&lt;br /&gt;
==Évolutions==&lt;br /&gt;
En dehors des habituelles mises aux points, bug, améliorations, réglages, interface, etc. Il serait souhaitable :&lt;br /&gt;
* d'améliorer le GUI, pour pouvoir créer / sélectionner / modifier chaque point de contrôle.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
En termes &amp;quot;informatique&amp;quot;, il devrait être possible pour accroître la lisibilité et la maintenance, d'intégrer l'ensemble du code fichiers *.mip qui actuellement sont linéairement intégrés à Improccoordinator.cc, dcrop.cc et simpleprocess.cc à des procédures &amp;quot;void&amp;quot;, à l'exemple de rgbproc.cc&lt;/div&gt;</summary>
		<author><name>Sguyader</name></author>
	</entry>
	<entry>
		<id>http://rawpedia.rawtherapee.com/index.php?title=Local_Adjustments/fr&amp;diff=3298</id>
		<title>Local Adjustments/fr</title>
		<link rel="alternate" type="text/html" href="http://rawpedia.rawtherapee.com/index.php?title=Local_Adjustments/fr&amp;diff=3298"/>
		<updated>2017-10-26T17:38:11Z</updated>

		<summary type="html">&lt;p&gt;Sguyader: /* Réduction des défauts: capteur sale - yeux rouges - ... */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Quel type de contrôle local? ==&lt;br /&gt;
Lorsqu'on observe les différents logiciels du marché on trouve plusieurs types de contrôles locaux&lt;br /&gt;
# les contrôles de type &amp;quot;lasso&amp;quot;, associés à des calques et masques de fusion, comme par exemple dans Photoshop (c). Ce type de contrôle est majoritaire dans les logiciels (Photoshop, Gimp, Darktable...) et l'avis des utilisateurs est obligatoirement orienté vers ceux-ci au détriment du point 3) ci-dessous moins connu!&lt;br /&gt;
# les dispositifs de suppression de &amp;quot;yeux rouges&amp;quot;, ou de &amp;quot;spot&amp;quot; liés aux imperfections du capteur&lt;br /&gt;
# les contrôles de type U-points, utilisés jusque récemment dans Nikon Capture NX2 (c), ou comme complément à d'autres logiciels comme Nik Software (c). Pour qui a tâté de ces dispositifs (rares maintenant) il n'est pas question de revenir aux calques et masques de fusion! Ce type de contrôle nécessite un apprentissage différent de ceux de type lasso-calque et un désapprentissage cognitif de ceux-ci. De mon point de vue, ils sont globalement plus performants.&lt;br /&gt;
&lt;br /&gt;
Dans la version présente de Rawtherapee, l’algorithme développé est proche dans le principe du point 3) ci-dessus, les U-points. Bien sûr, le code de Nik Software est inconnu, mais il y a quelques années j'ai été séduit par la facilité d'utilisation et les performances des U-points, et j'ai entrepris de développer un produit qui ne ferait pas appel, ni au lasso, ni aux calques, ni aux masques de fusion.&lt;br /&gt;
&lt;br /&gt;
Bien sûr rien n'interdit d'avoir les 3 possibilités (Lasso-calque, retouches spot, U-points) !&lt;br /&gt;
&lt;br /&gt;
La version actuelle est très certainement perfectible, au niveau de l'interface graphique - GUI - notamment:&lt;br /&gt;
* pour le suivi et repérage des RT-spot (spot de contrôle) à l'écran&lt;br /&gt;
* pour les réglages des différents curseurs qui gagneraient à être intégrés au spot de contrôle, comme le fait Nik Software (c).&lt;br /&gt;
Cependant, ces deux points n'affectent pas ni l’utilisation courante, ni la portabilité.&lt;br /&gt;
&lt;br /&gt;
J'ai ajouté, pour faciliter l'utilisation et éviter les menus trop longs en mode écran, une interface GUI similaire à celle de Wavelet, avec des &amp;quot;expanders&amp;quot;.&lt;br /&gt;
Vous avez ainsi la possibilité pour chaque famille d'action (color and light, Blur, Retinex, etc.):&lt;br /&gt;
# faire apparaître ou non le détail des commandes : curseurs, méthodes, courbes,..&lt;br /&gt;
# activer ou non l'ensemble des fonctions de la famille d'action.&lt;br /&gt;
Attention, le choix - 2 - active ou annule l'ensemble des RT-spot ( spot de contrôle); il est théoriquement possible d'associer cette possibilité à chaque RT-spot, mais quel intérêt ? &lt;br /&gt;
&lt;br /&gt;
===Contrôles locaux Lab et RGB===&lt;br /&gt;
* Les premiers algorithmes sont écrits en mode L*a*b* avec les contrôles suivants : &amp;quot;Color and Light&amp;quot;, &amp;quot;Blurr addnoise&amp;quot;, &amp;quot;Retinex&amp;quot;, &amp;quot;Tone mapping&amp;quot;, &amp;quot;Sharpen&amp;quot;, &amp;quot;CBDL&amp;quot;, &amp;quot;Denoise&amp;quot;..Deux contrôles suivants ont été ajoutés : &amp;quot;Exposure&amp;quot;, &amp;quot;Vibrance&amp;quot;...&lt;br /&gt;
* Voir ci-dessous le principe des algorithmes, mais un des points clefs à retenir pour la détection de forme et la prévention des artefacts est que le mode Lab préserve la teinte &amp;quot;hue&amp;quot;, qui joue un rôle déterminant.&lt;br /&gt;
* L'idée d'un module &amp;quot;RGB&amp;quot; vient évidemment à l'esprit, avec ''a minima'' un module :&lt;br /&gt;
** White Balance : qui permettrait une retouche de la balance des blancs par exemple pour &amp;quot;réchauffer les parties à l'ombre&amp;quot;, ou permettre le mélange de deux éclairages par exemple &amp;quot;lumière du jour&amp;quot; et &amp;quot;Tungsten&amp;quot;. Ce module doit être placé juste après &amp;quot;demosaic&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
====White balance auto====&lt;br /&gt;
Le module &amp;quot;white balance&amp;quot; (branche &amp;quot;autowblocal&amp;quot;) vise deux objectifs :&lt;br /&gt;
* permettre la retouche locale de la Balance des blancs (évident!)&lt;br /&gt;
* tester de nouveaux algorithmes de Balance des blancs automatique :&lt;br /&gt;
** en usage général (full image), afin d'obtenir de meilleurs résultats que l'algorithme actuel. Bien sûr on va me rétorquer qu'il faudrait une branche spécifique &amp;quot;White balance&amp;quot;, mais j'essaie de faire d'une pierre deux coups.&lt;br /&gt;
&lt;br /&gt;
Pour mémoire en 2012 et 2013, il m'avait été demandé, de mettre en place la balance des blancs itérative &amp;quot;Auto Robust WB[http://ieeexplore.ieee.org/document/1649677/]&amp;quot;. A l'époque avec un autre développeur nous avons passé beaucoup de temps pour un résultat assez peu satisfaisant... d'où l'abandon. Depuis, fort de cette expérience j'ai repris le travail mais à l'envers ! Maintenant - si je ne me suis pas trompé - l'algorithme fonctionne.&lt;br /&gt;
J'ai profité de cette possibilité (actuellement uniquement pour des images RAW), pour rechercher dans la littérature universitaire, d'autres algorithmes auto. J'ai trouvé et mis au point deux nouveaux algorithmes :&lt;br /&gt;
* &amp;quot;auto edge[https://www.researchgate.net/publication/301419990_A_Method_to_Improve_Robustness_of_the_Gray_World_Algorithm]&amp;quot; : l'idée ici est de créer un masque d’accentuation pour permettre de renforcer les parties de l'images où il y a des détails par rapport aux aplats.&lt;br /&gt;
* &amp;quot;auto standard deviation[http://www.acad.bg/rismim/itc/sub/archiv/Paper3_1_2012.pdf]&amp;quot; : l'image (ou la partie d'image pour le mode local) est divisée en 12 zones. Pour chacune on calcule moyenne et écarts type, puis on assemble le résultat.&lt;br /&gt;
Un troisième algorithme semble prometteur &amp;quot;Color by correlation[https://courses.cs.washington.edu/courses/cse467/08au/labs/l5/whiteBalance.pdf]&amp;quot;, mais je me heurte à quelques difficultés...Après beaucoup de tests en tous genres, les résultats sont erratiques...&lt;br /&gt;
&lt;br /&gt;
J'ai ajouté la notion de gamma:&lt;br /&gt;
* les mêmes principes concernant la répartition de la luminance - gamma sRGB - utilisé dans le code de Rawtherapee&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A titre de rappel, la balance des blancs automatique est un problème mathématique totalement indéterminé. Il est possible d'avoir des algorithmes plus ou moins performants (et aussi plus ou moins rapides ou lents), mais en aucun cas le résultat sera parfait ! Pourquoi est-ce impossible ? Si on se réfère aux principes de la gestion des couleurs [[http://rawpedia.rawtherapee.com/Color_Management_addon/fr#Balance_des_blancs]], il est nécessaire de connaitre à la fois l'objet coloré, l'illuminant et l'observateur. Il y a au moins 2 familles d'inconnues. De plus l'environnement de prise de vue n'est pas connu et influe sur la perception (CIECAM) ainsi que l'environnement de traitement et de visualisation. Donc, mission quasi impossible !&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'objectif du module '''&amp;quot;White balance&amp;quot; est de tester les algorithmes''', au total il y en a 7 et le double (au moins) si on prend en compte le &amp;quot;gamma sRGB&amp;quot;. En effet pour contourner les obstacles d'il y a 5 ans, j'ai utilisé au lieu de l'image avant demosaic, l'image juste après demosaic, sur laquelle on peut ou non appliquer le &amp;quot;gamma sRGB&amp;quot;, pour se retrouver dans les mêmes conditions qu'en usage normal (sinon bien sûr sans &amp;quot;White Balance&amp;quot; et sans profil &amp;quot;ICC ou DCP&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
L'idéal est de tester sur de nombreuses images les divers algorithmes &amp;quot;auto&amp;quot; avec un objectif : quel(s) algorithme(s) retenir et implanter en mode &amp;quot;full image&amp;quot; (peut être 1 ou 2 en plus de l'actuel qu'il faut garder pour compatibilité).&lt;br /&gt;
&lt;br /&gt;
====White balance contrôle local====&lt;br /&gt;
Le contrôle local est actuellement limité à 1 spot, mais pas de difficultés si les utilisateurs le souhaitent d’accroitre...En attendant les évolutions de &amp;quot;locallab&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Bien sûr il me sera dit &amp;quot;cela ne fonctionne pas&amp;quot;, ou &amp;quot;on ne se raccorde pas avec le 'preview'&amp;quot;. Cela fonctionne ! Et il est plus qu'évident que atteindre le preview est par définition quasi impossible... (différences ombres , soleil, illuminants différents, etc.) en dehors de la pertinence de l'algorithme.&lt;br /&gt;
&lt;br /&gt;
Vous disposez de 3 sliders : temperature, tint, blue/red equalizer&lt;br /&gt;
&lt;br /&gt;
== Quels défis à résoudre? ==&lt;br /&gt;
Plusieurs problèmes généraux sont à résoudre afin d'obtenir un fonctionnement fluide :&lt;br /&gt;
* permettre un nombre quasi illimité de RT-spot (spot de contrôles);&lt;br /&gt;
* adapter les algorithmes locaux aux problèmes d'échelle, car beaucoup d'algorithmes tiennent compte de la taille de l'image - donc de la zone traitée. Cet aspect est fondamental, notamment avec les courbes qui agissent sur toute l'image;&lt;br /&gt;
* minimiser l'occupation mémoire et les temps de traitement en sortie JPG et TIF;&lt;br /&gt;
* permettre des mises à jour logicielles faciles en cas d’évolution des algorithmes ou d'évolution du nombre de méthodes ;&lt;br /&gt;
* optimiser les écarts entre &amp;quot;preview&amp;quot; et sortie JPG / TIF; &lt;br /&gt;
* etc.&lt;br /&gt;
&lt;br /&gt;
Pour chaque RT-spot :&lt;br /&gt;
* permettre selon le cas, une action dans la zone sélectionnée ou à l'extérieur de la zone sélectionnée;&lt;br /&gt;
* permettre selon le cas une détection de forme pour délimiter l'action;&lt;br /&gt;
* assurer une transition entre le cœur de la zone traitée et le reste de l'image;&lt;br /&gt;
* etc.&lt;br /&gt;
&lt;br /&gt;
Actuellement, les RT-spot (spot de contrôles) sont opérationnels, pour le mode Lab, et pour les méthodes suivantes:&lt;br /&gt;
# Color and light : lightness, chrominance, contraste en mode normal avec quatre courbes L=f(L), L=f(H), C=f(C), H=f(H) et inverse ;&lt;br /&gt;
# Exposure : en mode normal&lt;br /&gt;
# Vibrance : en mode normal&lt;br /&gt;
# Blur and Noise : en mode normal et inverse;&lt;br /&gt;
# Retinex : en mode normal et inverse, maintenant avec gestion de la courbe &amp;quot;transmission gain&amp;quot;;&lt;br /&gt;
# Sharpening : en mode normal et inverse;&lt;br /&gt;
# Contrast By Detail Levels : en mode normal;&lt;br /&gt;
# Denoise : en mode normal.&lt;br /&gt;
&lt;br /&gt;
== Principes généraux ==&lt;br /&gt;
===L'Objet RT-spot===&lt;br /&gt;
Comme je l'ai évoqué, le système utilisé est proche de celui mis au point par Nik Software, avec de grandes différences :&lt;br /&gt;
* chaque RT-spot, peut être considéré comme un objet qui comporte plusieurs champ - à ce jour environ 70, constitués de curseurs, courbes;&lt;br /&gt;
* chaque champ, regroupé en paquets  peut être ou non activé, et peut avoir des valeurs variables selon sa nature ;&lt;br /&gt;
* les paquets sont des ensembles cohérents pour l'utilisateur : color &amp;amp; light, exposure, contrast, vibrance, blurr, retinex, sharpening, tone-mapping, contrast by detail level, denoise ;&lt;br /&gt;
* le nombre de &amp;quot;RT-spots objets&amp;quot; peut varier de 2 à 500 ;&lt;br /&gt;
* les données des &amp;quot;RT-spots objets&amp;quot; sont stockées dans un fichier texte &amp;quot;mip&amp;quot;;&lt;br /&gt;
* les &amp;quot;RT-spots objets&amp;quot; sont gérés - création, modification, suivi - dans une boucle &amp;quot;for&amp;quot;;&lt;br /&gt;
* il n'y a pas de duplication de code.&lt;br /&gt;
&lt;br /&gt;
===Le découpage en quatre zones - l’aperçu de la zone RT-spot===&lt;br /&gt;
Lorsque l’utilisateur sélectionne un RT-spot (spot de contrôle),l’image à l’écran montre:&lt;br /&gt;
* un centre, constitué d'un cercle dont on peut faire varier : a) le diamètre, b) la position avec la souris ou les curseurs;&lt;br /&gt;
* quatre lignes horizontales ou verticales dont on peut faire varier les positions avec la souris ou les curseurs.&lt;br /&gt;
* si vous sélectionnez en &amp;quot;Preferences&amp;quot; / &amp;quot;General&amp;quot; / &amp;quot;Local adjustements&amp;quot;, en cochant la case &amp;quot;Show spot delimiters&amp;quot;, vous obtiendrez une approximation de la zone concernée par le spot et ses réglages. Attention, je ne suis pas arrivé à un travail propre avec la fonction &amp;quot;arc / ellipse / scale&amp;quot; de la bibliothèque graphique Cairo; j'ai donc opté pour chaque &amp;quot;quart&amp;quot; à une pseudo ellipse obtenue par 3 courbes de Bézier se raccordant entre elles. Dans la majorité des cas l'approximation est satisfaisante...Pour permettre une sélection plus facile j'ai été amené à accroître la taille des 4 lignes horizontales et verticales qui sélectionnent la taille du spot (les courbes de Bézier sont inactives!).&lt;br /&gt;
&lt;br /&gt;
On aboutit à 4 zones, dont on ne peut faire varier l'orientation (angle d'inclinaison obligatoirement à zéro).&lt;br /&gt;
Ces 4 zones ont chacun de leurs sommets reliés par une ellipse imaginaire. &lt;br /&gt;
&lt;br /&gt;
Il est possible de pointer les limites des zones en dehors de la zone &amp;quot;preview&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
A terme, il doit être possible, même si l'utilité me semble discutable du fait de l'algorithme de détection de forme, de remplacer l'ellipse, par une courbe tracée à l'aide de la souris, à condition que la transformée homothétique de la courbe n'ait pas d'intersection avec la courbe originale. Cette &amp;quot;amélioration&amp;quot; intellectuellement satisfaisante, ne devrait être que d'un apport négligeable - dans le cas des U-points. Néanmoins il sera toujours possible de faire coexister les actuels U-points avec des contrôles par&amp;quot;lasso&amp;quot; de type Photoshop (c).&lt;br /&gt;
&lt;br /&gt;
===Les références teinte, chroma, luminance et le principe de l'algorithme en mode &amp;quot;normal&amp;quot;===&lt;br /&gt;
Afin de mettre en œuvre un algorithme performant de détection de forme :&lt;br /&gt;
* la zone du cercle central, sert de référence. En fonction du diamètre choisi par l'utilisateur, le système calcule, la moyenne de la teinte (hue), de la chroma, et de la luminance.&lt;br /&gt;
* le choix du diamètre de la zone centrale dépend de l'usage. Par exemple pour un feuillage, l'utilisateur aura intérêt à choisir une valeur faible afin de ne sélectionner que le vert du feuillage; à l'inverse pour la peau l'utilisateur aura intérêt  à accroître le diamètre afin d'éviter les prises en compte de données parasites (bruit, cils, etc.).&lt;br /&gt;
* pour chaque quart, et en fonction du curseur &amp;quot;scope&amp;quot;, le système prend en compte :&lt;br /&gt;
# en premier lieu de l'écart de teinte entre la zone centrale et le pixel courant ;&lt;br /&gt;
# puis, un algorithme complexe, s'appuyant sur la notion de deltaE (différence perçue entre 2 couleurs prenant en compte, la teinte, la chroma et la luminance), atténue l'action en fonction de l'écart entre la zone centrale et le pixel courant.&lt;br /&gt;
# la modification d'action utilise soit une loi linéaire, soit une loi parabolique selon le cas.&lt;br /&gt;
&lt;br /&gt;
Ceci va permettre de différencier l'action selon les critères énoncés ci-dessus, comme par exemple, si le cercle central se trouve dans un feuillage, de limiter l'action à l'ensemble du feuillage sans toucher à l'arrière plan (ce qui est impossible avec un lasso). De plus si un autre feuillage se situe dans la zone couverte, celui-ci sera également concernés par la modification.&lt;br /&gt;
&lt;br /&gt;
* l'action sur le curseur transition va permettre de faire varier l'action : si le curseur est réglé sur 50, la moitié (linéaire) de la zone concernée verra une application à 100% de l'effet, puis une transition agira régressivement jusqu'aux limites de la zone.&lt;br /&gt;
* si on accroît la valeur de &amp;quot;scope&amp;quot;, progressivement l’ensemble de la zone sélectionnée est prise en compte quelque soit la couleur, la chroma et la luminance. &lt;br /&gt;
* si on réduit la valeur de &amp;quot;scope&amp;quot;,l'action se limitera aux pixels très proches (en termes de deltaE) de la zone de référence.&lt;br /&gt;
&lt;br /&gt;
L'algorithme de détection de forme est opérationnel en mode &amp;quot;normal&amp;quot; sauf pour certains modules (denoise) - son implantation en mode inverse n'a pas de sens.&lt;br /&gt;
&lt;br /&gt;
Cet algorithme va avoir ses performances accrues, si l'utilisateur choisit : &amp;quot;Quality Enhanced&amp;quot; ou &amp;quot;Qualty enhanced + chroma denoise&amp;quot;. Ce second choix apporte une très légère réduction du bruit de chroma afin de supprimer les artefacts possibles liés à l'utilisation de &amp;quot;enhanced&amp;quot; (à noter dans le cas + chroma denoise, un accroissement des besoins en mémoire et du temps de traitement).&lt;br /&gt;
&lt;br /&gt;
L'algorithme utilise toutes ses capacités, si les valeurs de &amp;quot;scope&amp;quot; sont inférieures à 20.&lt;br /&gt;
&lt;br /&gt;
===Pourquoi pas d'autres algorithmes? ===&lt;br /&gt;
Remarque : il doit être possible de programmer d'autres algorithmes de détection de forme que celui ci-dessus fondé sur les différences de deltaE. &lt;br /&gt;
&lt;br /&gt;
* Par exemple les algorithmes de détection de bords (edge) tels que &amp;quot;Canny&amp;quot; ou &amp;quot;Sobel&amp;quot;;&lt;br /&gt;
* Ou encore le principe de décomposition en ondelettes.&lt;br /&gt;
Mais dans ces 2 cas tout reste à faire !&lt;br /&gt;
&lt;br /&gt;
===Le fonctionnement en mode inverse===&lt;br /&gt;
Lorsqu'il est proposé, le fonctionnement en mode inverse est extrêmement simplifié, seul le curseur &amp;quot;transition&amp;quot; permet de moduler l'action.&lt;br /&gt;
&lt;br /&gt;
A partir de fin octobre 2017, j'ai mis au point une autre manière de concevoir le mode &amp;quot;inverse&amp;quot;. Cette manière est limitée à l'outil &amp;quot;Blur and Noise&amp;quot; (voir ce paragraphe)&lt;br /&gt;
&lt;br /&gt;
===Nombre maximum de RT-spot (spot de contrôle)===&lt;br /&gt;
Par défaut le nombre de RT-spot est de 8.&lt;br /&gt;
Vous pouvez choisir n'importe quelle valeur entre 2 et 499. Pour cela il suffit de changer la variable Nspot dans le fichier &amp;quot;option&amp;quot;; par exemple Nspot=12.&lt;br /&gt;
Il est indispensable de relancer Rawtherapee après cette modification.&lt;br /&gt;
&lt;br /&gt;
===L'algorithme 'super'===&lt;br /&gt;
La clef du &amp;quot;succès&amp;quot; (si on peut utiliser ce terme) tient à l'algorithme présent depuis fin janvier 2017. je vais l'expliciter de manière simplifiée :&lt;br /&gt;
# pour la partie des données concernées par la zone sélectionnée, on applique une fonction courbe &amp;quot;traditionnelle&amp;quot; ou un curseur classique, ou la fonction de transfert normale (Retinex, Tone mapping, CBDL, Vibrance, ...);&lt;br /&gt;
# puis on réalise une conversion de la LUT ou de la fonction de transfert , en un équivalent &amp;quot;slider&amp;quot;, en séparant les valeurs positives et négatives, afin d'avoir une représentation de la fonction comme une multitude de &amp;quot;sliders&amp;quot; (autant qu'il y a de pixels concernés) dans l'intervalle -100, 0, +100&lt;br /&gt;
# on passe ces données à la fonction de reconnaissance de forme - celle des 4 zones. On détecte pour chaque pixel l'écart de teinte, chroma et luma par rapport à la référence. On établit des équations de variations linéaire selon le cas de la luminance (L = f(L)) ou de la chroma (C=f(C) ou des fonctions de transfert).&lt;br /&gt;
# puis on applique diverses corrections pour tenir compte de l'environnement, ciel, peau,...&lt;br /&gt;
# enfin, on applique une correction (avec seuil et itérations)pour ne pas corriger (ou le faire faiblement selon le choix de l'utilisateur), les tons gris ou neutres qui sont dans la même teinte que la référence (mais avec une chroma faible).&lt;br /&gt;
# ces paramètres sont ensuite pondérés en fonction, de la forme (ellipse) et de la zone de transition.&lt;br /&gt;
# bien sûr les réglages des paramètres qualité &amp;quot;Global quality&amp;quot;, ont leur importance, notamment dans les images légèrement bruitées - le bruit chromatique est considéré par l'algorithme comme de la même couleur que le spot. Il faut donc avoir la possibilité de le supprimer, d'où la sélection &amp;quot;enhanced + chroma denoise&amp;quot; (il est possible que ce réglage soit insuffisant, agir en conséquence sur &amp;quot;Denoise local&amp;quot; si nécessaire).&lt;br /&gt;
&lt;br /&gt;
Cet algorithme nouveau ('super') semble généralement fonctionner, mais dans le cas où le spot est sur une zone gris - neutre ou l'action sur des zones à faible gradient, l'algorithme peut être pris en défaut, dans ce cas utiliser l'ancien (quand c'est possible !!), car pour Retinex, Tone Mapping, CBDL je n'ai pas offert ce choix par souci de simplification)&lt;br /&gt;
&lt;br /&gt;
===Réduction des artefacts et l'algorithme &amp;quot;Global quality&amp;quot;===&lt;br /&gt;
Par défaut, &amp;quot;Global quality&amp;quot; est à &amp;quot;Enhanced + chroma denoise&amp;quot;. Certes cela augmente les temps de traitements, mais globalement c'est préférable. Vous pouvez, si vous trouvez les temps de rafraichissement long, choisir &amp;quot;enhance&amp;quot; ou &amp;quot;standard&amp;quot; et examiner l'image...&lt;br /&gt;
* 2 curseurs permettent de réduire les artefacts et améliorer le rendu de l'algorithme. Ils agissent en fonction de la chroma, dans les tons gris neutres. Pour désactiver complètement l'effet il suffit de mettre &amp;quot;iterations = 0&amp;quot;. Ces curseurs permettent, d'une part de réduire les artefacts et,  d'autre part d'agir sur le rendu de l'image. L'action est possible pour &amp;quot;Color Light&amp;quot;, &amp;quot;Exposure&amp;quot;, &amp;quot;Retinex&amp;quot;, &amp;quot;Vibrance&amp;quot;, &amp;quot;Tone Mapping&amp;quot; et &amp;quot;Contrast by details levels&amp;quot;.&lt;br /&gt;
* lorsque les images sont bruitées, même légèrement (beaucoup d’images sont bruitées sans que cela soit gênant par exemple les ciels, les nuages,...), les algorithmes sont &amp;quot;trompés&amp;quot;, ne pas hésiter à laisser activé &amp;quot;Global quality = enhanced + chroma denoise&amp;quot; et (quelquefois) activer &amp;quot;denoise local&amp;quot; et agir très légèrement sur les curseurs (y compris luminance). &lt;br /&gt;
* dans certaines circonstances, par exemple avec Tone-mapping, le système de réduction d'artefacts peut générer des artefacts. Dans ce cas, mettre le slider &amp;quot;iterations&amp;quot; à 0.&lt;br /&gt;
&lt;br /&gt;
Vous pouvez choisir la valeur par défaut de &amp;quot;Global Quality&amp;quot;, par exemple si vos images sont très peu bruitées, et ainsi réduire notablement les temps de traitement.&lt;br /&gt;
Pour cela, aller dans &amp;quot;Preferences&amp;quot;, &amp;quot;Performance and Quality&amp;quot;, &amp;quot;Local adjustements&amp;quot; et choisir entre Les 3 propositions. C'est ce choix qui sera proposé par défaut à l'utilisateur pour chaque nouveau &amp;quot;Spot&amp;quot;, bien sûr il est possible ensuite de modifier ce choix, en sélectionnant la combo-box &amp;quot;Global Quality&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Avoid color shift===&lt;br /&gt;
Cette case à cocher vise deux objectifs :&lt;br /&gt;
* mettre les couleurs dans le gamut de l'espace de travail courant (working profile) en utilisant une colorimétrie relative ;&lt;br /&gt;
* ajuster les couleurs à l'aide d'une correction &amp;quot;Munsell&amp;quot; - notamment les rouges-orangés et les bleus-pourpres, lorsque la saturation dans le domaine L*a*b* a évolué notablement.&lt;br /&gt;
&lt;br /&gt;
===Les fichiers *.mip - les principes de l’algorithme multipoints=== &lt;br /&gt;
Afin de permettre le fonctionnement - enregistrement des valeurs pour chaque spot de contrôle - un fichier de type texte, assez proche des fichiers pp3 est enregistré à deux endroits possibles :&lt;br /&gt;
* à côté du fichier à traiter. Si par exemple vous traitez le fichier ASC4509.NEF, un fichier ASC4509.NEF.mip sera enregistré dans le même dossier. Si vous choisissez cet emplacement, vous pourrez ouvrir plusieurs sessions pour un même fichier image, si celui-ci est présent dans des dossiers différents. Par contre, le nom des dossiers et du &amp;quot;path&amp;quot; doit obligatoirement n'avoir que des caractères ASCII...sinon plantage. &lt;br /&gt;
* dans le dossier &amp;quot;mip&amp;quot;, à l'intérieur du dossier &amp;quot;cache&amp;quot; (via un &amp;quot;hash number MD5&amp;quot; qui identifie le fichier). Valeur par défaut. Si vous choisissez cet emplacement, si le fichier image est présent dans plusieurs dossiers, il y aura plusieurs fichiers mip. Cette option permet d'utiliser des dossiers et &amp;quot;path&amp;quot; avec des caractères NON ASCII.&lt;br /&gt;
* le choix entre ces emplacements est possible à partir de : Preferences / Image processing / Mip Profiles&lt;br /&gt;
 &lt;br /&gt;
Ce fichier mip contient les données qui seront ensuite passées au programme, via d'une part les processus de type &amp;quot;procparams&amp;quot; et d'autre part des LUT qui permettent le fonctionnement en mode zoom.&lt;br /&gt;
Lors de la mise à jour d'une nouvelle version, il pourra dans certains cas être demandé d'effacer les fichiers *.mip (voire le cache)  afin d'éviter un crash. Pour cela vous pouvez aller dans &amp;quot;Preferences&amp;quot; / &amp;quot;Files browser&amp;quot;, puis &amp;quot;Clear mip&amp;quot; et / ou &amp;quot;clear pp3&amp;quot; - si bien sûr vous avez positionné &amp;quot;mip&amp;quot; et &amp;quot;pp3&amp;quot; dans le cache, sinon il faudra exécuter cette opération manuellement dans le dossier courant. La présence d'anciennes versions de fichiers &amp;quot;mip&amp;quot; ou de &amp;quot;pp3&amp;quot; peut amener de l'instabilité voire un crash du système. &lt;br /&gt;
&lt;br /&gt;
====Architecture du système====&lt;br /&gt;
Lorsque je me suis &amp;quot;aventuré&amp;quot; vers la possibilité d'un système multipoints sans calques, sans masques,...il était obligatoire de refuser de dupliquer le code. Comment envisager par exemple pour 10 spot de contrôles, 10 codes GUI, et autant de code dans Rtengine.&lt;br /&gt;
Après réflexion, l’idée est venue d'avoir un fichier mis à jour en temps réel - c'est à dire qui suit les modifications faites par l'utilisateur - de l’historique des actions / modifications.&lt;br /&gt;
&lt;br /&gt;
Bien sûr, les variables utilisées par Rawtherapee, au niveau de l'interface GUI, et par la suite dans l'ensemble du code via &amp;quot;params&amp;quot;, sont de type divers:&lt;br /&gt;
* numériques : entier, float,  double,...&lt;br /&gt;
* booléenne&lt;br /&gt;
* choix (menus pour &amp;quot;méthodes&amp;quot;) de type string&lt;br /&gt;
* courbes via des &amp;quot;vectors&amp;quot; de type double a dimension dynamique.&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
====Conversion des données====&lt;br /&gt;
La première étape - afin de simplifier ensuite la gestion des données - est de convertir toutes ces données en entiers. Dans quelques cas cela peut aboutir à une très légère perte de précision, qui de mon point de vue est tout à fait négligeable.&lt;br /&gt;
*Cette opération est très simple pour les valeurs numériques, même si elle peut aboutir dans certains cas (la teinte  - Hue - s'exprime en radians dans l’intervalle -Pi + Pi) par une double transformation &amp;quot;float * 100 et / 100&amp;quot; pour garder la précision.&lt;br /&gt;
*Elle est logique pour les opérations booléennes et les méthodes.&lt;br /&gt;
*Par contre elle s'est avérée complexe pour les courbes. Les valeurs à stocker dans le fichier texte sont de type vector&amp;lt;double&amp;gt; soit un tableau dynamique de valeurs numériques. Probablement il doit y avoir un moyen &amp;quot;plus simple&amp;quot; en utilisant les fonctions qui sont utilisées dans &amp;quot;Procparams&amp;quot;, mais je ne suis pas arrivé à les mettre en œuvre. J'ai contourné l'obstacle en :&lt;br /&gt;
#transformant les valeurs doubles en entier avec 3 chiffres significatifs - ce qui est largement suffisant&lt;br /&gt;
#puis en convertissant le &amp;quot;vector&amp;quot; en une chaine de caractère de longueur variable&lt;br /&gt;
#la lecture et l'écriture de cette chaine et sa conversion en &amp;quot;vector&amp;quot; se faisant dynamiquement par une fonction appropriée (&amp;quot;strcurv_data&amp;quot;). A noter que cette fonction permet de modifier des courbes jusqu'à une limite de 16 points d'inflexion (Courbe de Beziers) pour la courbe plate, et 32 pour la diagonale, ce qui devrait être suffisant. Si c'était insuffisant (??) il est possible (via une perte de compatibilité) d'accroître ce nombre.&lt;br /&gt;
&lt;br /&gt;
====Quelques éléments sur les courbes====&lt;br /&gt;
L'implémentation des courbes a été complexe, au delà de ce qui est écrit ci-dessus, notamment :&lt;br /&gt;
# chaque courbe doit obligatoirement avoir une fonction reset - resize() à chaque itération;&lt;br /&gt;
# ce qui implique des curiosités au niveau de leur description, par exemple la courbe diagonale est initialisée avec plusieurs points, alors qu'elle a l'air &amp;quot;vide&amp;quot;. C'est indispensable au bon fonctionnement. Mais ceci a pour conséquence que cette courbe est toujours ouverte / active. Donc cela implique si on veut éviter des consommations de temps en mode &amp;quot;preview&amp;quot; que l'utilisateur &amp;quot;active&amp;quot; la courbe en activant la combobox &amp;quot;curves&amp;quot;. Cette même activation est aussi nécessaire pour les courbes L=f(H) et C=f(C). Bien sûr, on se serait tenté de penser qu'il suffit d'activer le mode &amp;quot;enabled&amp;quot; de la fonction &amp;quot;courbes&amp;quot; (linéaire), mais après de nombreux essais cette démarche est infructueuse!&lt;br /&gt;
# tout au long des procédures, il est obligatoire de mettre &amp;quot;clear&amp;quot; chaque valeur de &amp;quot;params&amp;quot; pour les courbes, chaque LUT, pour chaque itération et ensuite via &amp;quot;vector&amp;quot; de réattribuer les bonnes valeurs courantes à &amp;quot;params courbe&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
====Stockage et utilisation dynamique des données====&lt;br /&gt;
Une fois les données converties :&lt;br /&gt;
* elles sont stockées dans un fichier texte&lt;br /&gt;
* chacune est référencée dans un tableau dynamique à deux dimensions : &lt;br /&gt;
# dataspot[x][y], pour les valeurs numériques, booléenne et les méthodes,   où 'x' représente l'indice représentatif de la variable, par exemple '9' correspond à 'Lightness', et 'y' représente le RT-spot (spot de contrôle) courant. La valeur '0' représente la valeur courante en cours d'utilisation (celle stockée dans 'params&amp;quot;). &lt;br /&gt;
# retistr[y], llstr[y], lhstr[y], ccstr[y], hhstr[y], skinstr[y], pthstr[y], exstr[y] pour les variables de type &amp;quot;curve&amp;quot; (aujourd'hui il n'y a que 8 variables celle utilisée dans &amp;quot;Retinex&amp;quot; local, et celles dans &amp;quot;Color and light&amp;quot; (L=f(L), C=f(C), L=f(H), H=F(H))et  &amp;quot;vibrance&amp;quot; et &amp;quot;exposure&amp;quot;,  mais il est assez facile d'en ajouter), avec 'y' comme ci-dessus.&lt;br /&gt;
&lt;br /&gt;
Ce stockage et utilisation - nous reviendrons plus loin sur l'algorithme lecture / écriture dynamique - convient aisément pour le fichier Improccoordinator.cc (support de la gestion courante - Preview) et Simpleprocess.cc (sortie TIF / JPG), mais ne peut convenir, pour Dcrop.cc et la vision partielle de l'image (les fameux pipeline de Rawtherapee).&lt;br /&gt;
&lt;br /&gt;
Pour ce cas (zoom - Preview) il a fallu imaginer autre chose, qui assure en temps réel la synchronisation des modifications. J'ai utilisé des LUT, dans le cas actuel, à chaque donnée référencée dans les tableaux ci dessus est associé une LUTi(z), avec z=500 entrées possibles (500 correspond à la limite informatique du nombre de RT-spot (spots de contrôles)...qu'on peut très facilement accroitre ou réduire). 'z' pour les LUTi correspond à 'y' pour dataspot. Une LUTi avec 25000 (arbitraire) entrées est utilisée  pour &amp;quot;retistr&amp;quot;, &amp;quot;llstr&amp;quot;, &amp;quot;lhstr&amp;quot;, &amp;quot;ccstr&amp;quot;, &amp;quot;hhstr&amp;quot;, &amp;quot;skinstr&amp;quot;, &amp;quot;pthstr&amp;quot;, &amp;quot;exstr&amp;quot; pour garder en mémoire (sous forme d'un entier) chaque valeur du 'Vector' de la courbe (il peut y en avoir jusque 69).&lt;br /&gt;
 &lt;br /&gt;
Au cours du traitement, des échanges sont réalisés entre: params, les tableaux dynamiques et les LUTi. Les valeurs utilisées par Dcrop.cc sont liées dynamiquement aux tableaux dynamiques par parent-&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
====Processus d'échanges et stockage des données dynamiques ====&lt;br /&gt;
Sans entrer dans une description fastidieuse, je resterais aux principes généraux :&lt;br /&gt;
# lecture du fichier &amp;quot;mip&amp;quot; pour lire la version et orienter  les mises à jour&lt;br /&gt;
# première écriture du fichier &amp;quot;mip&amp;quot; s'il n'existe pas&lt;br /&gt;
# stockage des données dans les LUTi et les tableaux dynamiques à partir des valeurs stockées dans &amp;quot;Params&amp;quot; (valeurs index 0)&lt;br /&gt;
# première mise à jour interactive avec le GUI via une fonction de transfert entre Rtengine et locallab.cc (aloListener-&amp;gt;localretChanged). Cette fonction fait partie des 3 nécessaires pour obtenir un fonctionnement correct.&lt;br /&gt;
# lecture du fichier texte &amp;quot;mip&amp;quot; et stockage des données dans les tableaux dynamiques (valeurs index ==&amp;gt; y) - selon le nombre de RT-spot (spots de contrôle)&lt;br /&gt;
# Création d'une boucle - selon le nombre de RT-spot (spots de contrôle)- où à partir des valeurs stockées dans les variables tableaux dynamique, les LUTi (nécessaires à Dcrop) et les valeurs de Params sont actualisées.&lt;br /&gt;
# Appel de la fonction &amp;quot;Lab_local&amp;quot; qui contient les algorithmes de contrôle de chaque RT-spot (luminance, Sharp, retinex, denoise, etc.)  &lt;br /&gt;
# deuxième mise à jour interactive avec le GUI via une autre fonction de transfert entre Rtengine et locallab.cc &lt;br /&gt;
# puis traitement du RT-spot (spot de contrôle) courant, en récupérant les valeurs index (0) des tableaux dynamiques. Ces valeurs sont attribuées à : 1) params, 2) LUTi, 3) valeurs index en cours&lt;br /&gt;
# Appel de la fonction &amp;quot;Lab_local&amp;quot; pour le RT-spot courant.&lt;br /&gt;
# sauvegarde du fichier &amp;quot;mip&amp;quot;&lt;br /&gt;
&lt;br /&gt;
A noter que si l'utilisateur, modifie une courbe, amplitude ou nombre de points d'inflexion, une troisième mise à jour interactive est réalisée pour mettre en conformité l’ensemble des données en fonction des événements.&lt;br /&gt;
&lt;br /&gt;
====Quelques fantaisies incontournables====&lt;br /&gt;
Bien sûr, tout à l'air simple, mais le système ne fonctionne que, si et seulement si, toutes les données sont dynamiquement mises à jour.&lt;br /&gt;
&lt;br /&gt;
J'ai beaucoup essayé, tâtonné, pour aboutir à une solution qui fonctionne...certes curieuse; il y a probablement un moyen plus &amp;quot;informatique&amp;quot; de traiter cela, mais à ce stade, j'ai fait comme décrit ci-dessus et ci-après.&lt;br /&gt;
&lt;br /&gt;
Les 3 échanges entre Rtengine et le GUI se font notamment avec 3 variables qui ne servent à rien dans le programme - sinon à mettre à jour:&lt;br /&gt;
# &amp;quot;anbspot&amp;quot; qui prend les valeurs forcées 0 ou 1&lt;br /&gt;
# &amp;quot;cTgainshaperab&amp;quot; (curve), dont je fais osciller une valeur entre 0.70 et 0.90&lt;br /&gt;
# &amp;quot;retrab&amp;quot; qui oscille autour de 500.&lt;br /&gt;
&lt;br /&gt;
J'ai ajouté 3 variables (sous forme de &amp;quot;sliders&amp;quot;) - hueref, chromaref, lumaref, totalement invisibles à l'utilisateur, mais qui servent à rafraichir le système en temps réel, pour permettre la bonne prise en compte des valeurs &amp;quot;spot&amp;quot; de référence.  &lt;br /&gt;
&lt;br /&gt;
Les appels aux changements de ces 3 variables amènent la stabilité au système et une mise à jour en temps réel.&lt;br /&gt;
Il ne devrait pas être nécessaire d’accroitre le nombre de ces variables &amp;quot;fantaisistes&amp;quot; &lt;br /&gt;
&lt;br /&gt;
De plus j'ai été amené à empiriquement mettre des temporisations, pour laisser le temps au temps... C'est notamment le cas pour la modification de la courbe par l’utilisateur (amplitude, nombre de points d'inflexion).&lt;br /&gt;
&lt;br /&gt;
Bien sûr ces variables  sont invisibles pour l'utilisateur, sinon dans l'historique !&lt;br /&gt;
&lt;br /&gt;
==Quelques particularités du mode local (par rapport à Lab adjustements)==&lt;br /&gt;
&lt;br /&gt;
Voici quelques informations qui peuvent intéresser l'utilisateur. Ces informations sont souvent des particularités du mode local&lt;br /&gt;
&lt;br /&gt;
===Color and Light===&lt;br /&gt;
*Les algorithmes utilisés pour la luminance et le contraste sont différents de ceux utilisés par &amp;quot;Lab adjustements&amp;quot;, ce qui peut amener quelques différences de rendu.&lt;br /&gt;
*L'algorithme de luminance est réalisé de telle manière que en dessous de -90 et jusque -100 pour &amp;quot;lightness&amp;quot;, il est possible d'accroître la &amp;quot;darkness&amp;quot; de l'image, pratiquement jusqu'à obtenir une valeur de luminance proche de 0. Si vous souhaitez accentuer cet effet, réduisez également la chominance et accroissez &amp;quot;scope&amp;quot;.&lt;br /&gt;
*Le mode inverse, peut servir pour l'essentiel, à réaliser des cadres dégradés. Dans ce cas, si vous sélectionnez -100 pour &amp;quot;lightness&amp;quot;, et réduisez la chrominance, la &amp;quot;bordure&amp;quot; sera noire.&lt;br /&gt;
* pour la luminance et le contraste (curseur), vous avez le  choix entre 2 algorithmes : le premier (par défaut) est très proche de ce qui était présent jusque là, le second activé par &amp;quot;Lightness Contrast super&amp;quot; est proche de celui utilisé pour les courbes &amp;quot;super&amp;quot;&lt;br /&gt;
* ne pas hésiter selon le cas, à activer &amp;quot;Global quality&amp;quot; = enhanced  et (défaut) enhanced + chroma denoise&amp;quot;&lt;br /&gt;
====Courbes====&lt;br /&gt;
*Une courbe L=f(L) et une C=f(C) permet de moduler la luminance ou la chrominance pour chaque RT-spot (spot de contrôle) en fonction de la luminance ou de la chrominance. &lt;br /&gt;
*Une courbe L=f(H) permet de moduler la luminance pour chaque RT-spot en fonction de la teinte. &lt;br /&gt;
*Une courbe H=f(H) permet de moduler la teinte pour chaque RT-spot en fonction de la teinte.&lt;br /&gt;
Pour les rendre actives, il est nécessaire d'activer la combobox &amp;quot;Curves type&amp;quot;.&lt;br /&gt;
* deux choix sont offerts : &lt;br /&gt;
** a) Normal : les courbes - notamment la plus complexe à gérer L=f(L) utilise un algorithme proche de celui utilisé avec les curseurs (mode Normal);&lt;br /&gt;
** b) Super : utilise un nouvel algorithme que je pense très performant (le résultat m'a même surpris à la première utilisation).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Attention, lorsque le spot est située dans une zone grise, ou des zones assez uniformes, les artefacts avec le nouvel algorithme (L=F(L) super, et Lightness Contrast super) peuvent être impossible à supprimer, dans ce cas privilégier l’algorithme &amp;quot;normal&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Exposure===&lt;br /&gt;
Ce module &amp;quot;ressemble&amp;quot; à celui en mode global RGB, mais :&lt;br /&gt;
* il fonctionne entièrement en mode L*a*b*, d'où des différences de rendu;&lt;br /&gt;
* il n'a pas les curseurs &amp;quot;lightness, chroma et contraste&amp;quot; dont les fonctions sont déjà présentes dans &amp;quot;Color and Light&amp;quot;&lt;br /&gt;
* il y a une seule courbe &amp;quot;contraste&amp;quot;, similaire à celle de L=F(L) présente dans &amp;quot;Color and Light&amp;quot;. Il est évident que le rendu de cette courbe est différent de &amp;quot;Tonecurve&amp;quot; qui agit en mode RGB. Vous pouvez si vous le souhaitez activer les 2 courbes L=f(L) dans &amp;quot;Color and Light&amp;quot; et &amp;quot;Exposure&amp;quot; &lt;br /&gt;
&lt;br /&gt;
===Vibrance===&lt;br /&gt;
Module similaire à celui du menu principal.&lt;br /&gt;
&lt;br /&gt;
===Blur and Noise===&lt;br /&gt;
Blur n'est actif que si Radius supérieur ou égal à 2.&lt;br /&gt;
&lt;br /&gt;
En réduisant notablement la valeur par défaut de &amp;quot;scope&amp;quot; et en agissant éventuellement sur &amp;quot;Luminance only&amp;quot; il est possible d'obtenir des flous différenciés selon la teinte.&lt;br /&gt;
&lt;br /&gt;
Vous disposez (octobre 2017), de 3 méthodes :&lt;br /&gt;
* &amp;quot;normal&amp;quot; : l'algorithme de détection de forme a été amélioré. Il se rapproche de celui utilisé dans les autres modules.&lt;br /&gt;
* &amp;quot;inverse&amp;quot; : algorithme simplifié, ne faisant pas intervenir &amp;quot;scope&amp;quot;. L'inversion est grossière et ne permet pas une séparation fine des zones à traiter / conserver.&lt;br /&gt;
* &amp;quot;symmetric&amp;quot; : ce nouvel algorithme utilise les mêmes processus que &amp;quot;normal&amp;quot; et par l'utilisation de &amp;quot;scope&amp;quot; l'utilisateur peut cibler plus précisément l'action. &lt;br /&gt;
&lt;br /&gt;
Attention:&lt;br /&gt;
* travailler en mode inverse, va flouter des zones importantes qui ne pourront pas être corrigées ensuite&lt;br /&gt;
* l'action de &amp;quot;scope&amp;quot; peut être déroutante dans certains cas : par exemple pour un portrait les yeux - différents de la peau - seront floutés si &amp;quot;scope&amp;quot; est trop faible.&lt;br /&gt;
&lt;br /&gt;
===Tone mapping===&lt;br /&gt;
Attention aux artefacts lorsque les aplats (ciels, zones grises...) sont d'une teinte similaire au spot de contrôle. Dans le cas d'artefacts, mettre le curseur &amp;quot;iterations&amp;quot; de &amp;quot;Reduce artefacts - improve algorithm&amp;quot; à zéro.&lt;br /&gt;
&lt;br /&gt;
===Retinex===&lt;br /&gt;
Le nombre de réglages est réduit, par rapport au mode standard. D'autre part, &amp;quot;Retinex local&amp;quot; agit en fin de processus contrairement au mode standard qui est au début du processus Raw.&lt;br /&gt;
Depuis la version mip 10002, la courbe &amp;quot;transmission gain&amp;quot; est spécifique à chaque RT-spot.&lt;br /&gt;
&lt;br /&gt;
===Sharpening===&lt;br /&gt;
Seul le mode &amp;quot;RL deconvolution&amp;quot; est proposé.&lt;br /&gt;
&lt;br /&gt;
===Contrast By Detail Levels===&lt;br /&gt;
* 5 niveaux au lieu de 6 pour le mode pleine image.&lt;br /&gt;
* pas de curseurs pour la gestion de la peau; le système utilisé par les RT-spot le remplace.&lt;br /&gt;
* ajout d'un curseur pour la chroma&lt;br /&gt;
* Attention aux artefacts lorsque les aplats (ciels, zones grises...) sont d'une teinte similaire au RT-spot. Dans le cas d'artefacts, mettre le curseur &amp;quot;iterations&amp;quot; de &amp;quot;Reduce artefacts - improve algorithm&amp;quot; à zéro.&lt;br /&gt;
&lt;br /&gt;
===Denoise===&lt;br /&gt;
* par rapport au mode pleine image, seul l'outil wavelet est utilisé: donc pas de fonction de Fourier, ni de medians&lt;br /&gt;
* moins de curseurs et de courbes&lt;br /&gt;
* par contre, vous pouvez différencier l'action sur la luminance et la chrominance en fonction de la grosseur du bruit - fine ou coarse.&lt;br /&gt;
&lt;br /&gt;
==Cas d'usage spécifique : réduction des défauts (capteur sale, yeux rouges, ...)==&lt;br /&gt;
Par conception &amp;quot;Locallab&amp;quot; n'a pas été conçu pour éliminer ces défauts. Néanmoins par effet de bord, certains défauts apparents et gênant en photographie peuvent être réduits voire supprimés. Ceci bien sûr n'est pas incompatible avec d'autres modules plus spécialisés incorporés ou non à &amp;quot;Locallab&amp;quot;...&lt;br /&gt;
Au moins 3 fonctions présentes, en adaptant l'usage, peuvent être utilisées, séparément ou ensemble :&lt;br /&gt;
* &amp;quot;Color and light&amp;quot; pour des défauts ponctuels ;&lt;br /&gt;
* &amp;quot;Contrast by detail level&amp;quot; pour des défauts répartis ;&lt;br /&gt;
* &amp;quot;Blur and Noise&amp;quot; en complément éventuel : attention cette action est assez destructrice - à utiliser avec modération.&lt;br /&gt;
&lt;br /&gt;
Vous pouvez agir soit:&lt;br /&gt;
* directement, cas général, sur le fichier &amp;quot;raw&amp;quot;, ou &amp;quot;TIF&amp;quot;, etc.&lt;br /&gt;
* soit sur le fichier flat-field si vous en avez élaboré un.&lt;br /&gt;
  &lt;br /&gt;
===Utilisation avec le module &amp;quot;Color and Light&amp;quot;===&lt;br /&gt;
* Activez &amp;quot;Color and Light&amp;quot;&lt;br /&gt;
*Vous pouvez utiliser l'équivalent d'une fonction &amp;quot;yeux rouges&amp;quot; en choisissant un encadrement assez serré de l’œil - sélecteur circulaire centré sur le rouge, délimiteurs de spot proches de l’œil - une valeur de scope réduite, puis agir sur réduction &amp;quot;lightness&amp;quot; -100, et réduction chrominance -100.&lt;br /&gt;
*De la même manière vous pouvez réduire les défaut du capteur de type &amp;quot;Spot IR&amp;quot;,  en choisissant un encadrement assez serré du défaut - sélecteur circulaire centré sur le défaut, délimiteurs de spot proches du défaut - puis agir sur &amp;quot;chrominance&amp;quot; en réduisant la valeur, agir éventuellement sur &amp;quot;scope&amp;quot; pour réduire l'étendue de l'action.&lt;br /&gt;
*Vous pouvez dans des cas simples, réduire les défauts de type &amp;quot;capteur encrassé&amp;quot; notamment lorsque celui-ci est gras. Ceci se traduit par des taches qui apparaissent sur les fonds unis. Pour cela choisissez un encadrement assez serré du défaut - sélecteur circulaire centré sur le défaut (adaptez la taille du spot) , délimiteurs de spot pas trop proches du défaut pour permettre une transition peu visible. Puis: a) réduisez &amp;quot;Transition&amp;quot; à des valeurs faibles; b) cochez &amp;quot;Lightness contrast super&amp;quot;; c) agissez sur &amp;quot;luminance&amp;quot; et éventuellement sur &amp;quot;chrominance&amp;quot; pour approcher le rendu de la zone polluée à celui de la zone saine; d) agir modérément sur &amp;quot;scope&amp;quot; pour moduler l'action souhaitée.&lt;br /&gt;
&lt;br /&gt;
===Utilisation avec le module &amp;quot;Contrast by detail levels&amp;quot;===&lt;br /&gt;
Dans le cas de capteur encrassé (de type &amp;quot;graisse&amp;quot;), et lorsque la zone est importante ou pour une série de petits défauts, Il peut être utile d'utiliser &amp;quot;Contrast by details levels&amp;quot; qui va agir comme un outil &amp;quot;wavelet&amp;quot; sur la luminance et aussi si nécessaire sur la chrominance. Dans ce cas: a) mettez le Spot de sélection sur un défaut prononcé (en adaptant sa taille si nécessaire); b) choisissez une zone de sélection large pour couvrir la majorité de la surface concernée par les défauts; c)Sélectionnez une valeur de transition assez importante; d) Activez &amp;quot;Contrast by detail levels&amp;quot; et agissez sur les niveaux 3 et 4 ou plus faibles en réduisant le contraste (valeurs inférieures à 100) et en agissant si nécessaire sur le curseur chroma.&lt;br /&gt;
&lt;br /&gt;
== Temps de traitement et utilisation de la mémoire ==&lt;br /&gt;
&lt;br /&gt;
Lorsqu'on utilise la sortie JPG ou TIF, et pour le mode &amp;quot;normal&amp;quot;, l'algorithme n'effectue les calculs que pour la zone délimitée. En ce sens les temps de traitement et l'occupation mémoire sont réduits.&lt;br /&gt;
Bien sûr le temps de traitement va dépendre du nombre de spots de contrôles, de leur taille, et du type de traitement.&lt;br /&gt;
&lt;br /&gt;
Si on exclue &amp;quot;Denoise&amp;quot; et &amp;quot;Sharp&amp;quot;, les temps de traitement sont de l'ordre de quelques dixièmes de seconde par spot de contrôle, et le besoin en mémoire de l'ordre de quelques centaines de M.&lt;br /&gt;
&lt;br /&gt;
Deux réglages agissent fortement sur les temps de traitement et le besoin en mémoire :&lt;br /&gt;
* denoise qui ajoute selon la taille du spot de contrôle de l'ordre de 1 seconde et 1 M de mémoire.&lt;br /&gt;
* quality enhanced and chroma denoise, qui ajoute environ selon le spot de contrôle de l'ordre de 0.5 secondes et 0.6 M.&lt;br /&gt;
&lt;br /&gt;
==Onglet Preferences==&lt;br /&gt;
J'ai regroupé ici, les réglages (repris par ailleurs sur cette page) accessibles depuis &amp;quot;Preferences&amp;quot;&lt;br /&gt;
* si vous sélectionnez en &amp;quot;Preferences&amp;quot; / &amp;quot;General&amp;quot; / &amp;quot;Local adjustements&amp;quot;, en cochant la case &amp;quot;Show spot delimiters&amp;quot;, vous obtiendrez une approximation de la zone concernée par le spot et ses réglages&lt;br /&gt;
* Vous pouvez choisir la valeur par défaut de &amp;quot;Global Quality&amp;quot;, par exemple si vos images sont très peu bruitées, et ainsi réduire notablement les temps de traitement.Pour cela, aller dans &amp;quot;Preferences&amp;quot;, &amp;quot;Performance and Quality&amp;quot;, &amp;quot;Local adjustements&amp;quot; et choisir entre Les 3 propositions. C'est ce choix qui sera proposé par défaut à l'utilisateur pour chaque nouveau &amp;quot;Spot&amp;quot;, bien sûr il est possible ensuite de modifier ce choix, en sélectionnant la combo-box &amp;quot;Global Quality&amp;quot;&lt;br /&gt;
* Fichiers &amp;quot;mip&amp;quot;: &lt;br /&gt;
**le choix de l'emplacement est possible à partir de : Preferences / Image processing / Mip Profiles&lt;br /&gt;
** effacement : aller dans &amp;quot;Preferences&amp;quot; / &amp;quot;Files browser&amp;quot;, puis &amp;quot;Clear mip&amp;quot; et / ou &amp;quot;clear pp3&amp;quot; - si bien sûr vous avez positionné &amp;quot;mip&amp;quot; et &amp;quot;pp3&amp;quot; dans le cache, sinon il faudra exécuter cette opération manuellement dans le dossier courant. La présence d'anciennes versions de fichiers &amp;quot;mip&amp;quot; ou de &amp;quot;pp3&amp;quot; peut amener de l'instabilité voire un crash du système.&lt;br /&gt;
&lt;br /&gt;
==Évolutions==&lt;br /&gt;
En dehors des habituelles mises aux points, bug, améliorations, réglages, interface, etc. Il serait souhaitable :&lt;br /&gt;
* d'améliorer le GUI, pour pouvoir créer / sélectionner / modifier chaque point de contrôle.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
En termes &amp;quot;informatique&amp;quot;, il devrait être possible pour accroître la lisibilité et la maintenance, d'intégrer l'ensemble du code fichiers *.mip qui actuellement sont linéairement intégrés à Improccoordinator.cc, dcrop.cc et simpleprocess.cc à des procédures &amp;quot;void&amp;quot;, à l'exemple de rgbproc.cc&lt;/div&gt;</summary>
		<author><name>Sguyader</name></author>
	</entry>
	<entry>
		<id>http://rawpedia.rawtherapee.com/index.php?title=Local_Lab_Controls&amp;diff=3297</id>
		<title>Local Lab Controls</title>
		<link rel="alternate" type="text/html" href="http://rawpedia.rawtherapee.com/index.php?title=Local_Lab_Controls&amp;diff=3297"/>
		<updated>2017-10-26T17:36:30Z</updated>

		<summary type="html">&lt;p&gt;Sguyader: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What kind of local control?==&lt;br /&gt;
&lt;br /&gt;
Several types of local control exist in mainstream applications :&lt;br /&gt;
# “lasso”, associated with layers and fusion masks (e.g. Photoshop©). This kind of control is widespread (Photoshop, Gimp, Darktable…) and users tend to favor those, at the expense of the type desciribed in 3. below, which is less well known;&lt;br /&gt;
# dedicated tools for the removal of image defects such as “red eyes”, or “spots” associated with sensor imperfections or dirt;&lt;br /&gt;
# “U-points” controls, used until recently in Nikon Capture NX2©, or as an add-on to other software such as Nik Software©. For those (rare now) who tried such programs, there’s no way turning back to layers and fusion masks! This type of local control requires learning something different, and a cognitive “reprogramming”. In my opinion, this kind of local control is globally more efficient.&lt;br /&gt;
&lt;br /&gt;
The algorithm developed in the current version of RawTherapee is close in its principle to the U-points described above. Of course, the code used in Nik Software is not disclosed, but several years ago I was attracted by the simplicity of use and the efficiency of U-points, and I started developing a product which would use neither lassos, nor layers or fusion masks. Of course, nothing prevents us from having all 3 types of local control in the same program.&lt;br /&gt;
&lt;br /&gt;
The current version of the filter is perfectible, particularly regarding the user interface (GUI):&lt;br /&gt;
* for managing and viewing the RT-spots (control spots) on screen,&lt;br /&gt;
* for manipulating the different sliders, which would ideally be better if integrated to the actual control points, as done in Nik Software.&lt;br /&gt;
&lt;br /&gt;
However, those two aspects don’t harm everyday use, nor code portability.&lt;br /&gt;
&lt;br /&gt;
In order to improve manipulation and avoid long menus on screen, I added a GUI interface which is similar to the one used in the Wavelet tab, with “expanders”. Thus for each module (“Color and Light”, “Blur”, “Retinex”, …) you can choose to:&lt;br /&gt;
# display (or not) the full list of commands: sliders methods, curves…&lt;br /&gt;
# activate (or not) the all the functions of the module.&lt;br /&gt;
&lt;br /&gt;
Warning: choice 2. activates or cancels all the RT-spots; it would be possible in theory to add this capability to every single RT-spot, but for what purpose?&lt;br /&gt;
&lt;br /&gt;
===Lab and RGB local controls===&lt;br /&gt;
* The first algorithms are coded in L*a*b* mode with the following modules: “Color and Light”, “Blur / Add noise”, “Retinex”, “Tone mapping”, “Sharpen”, “Contrast by Detail Levels”, “Denoise”. Two additional modules have been added: “Exposure” and “Vibrance”.&lt;br /&gt;
* See below for the principles of the different algorithms, but one key point to remember for shape detection and artifacts avoidance, is that the Lab mode preserves the “hue” tint, which is crucial.&lt;br /&gt;
* The idea of an “RGB” module comes to one’s mind, with ''a minima'':&lt;br /&gt;
** a “White balance” module, which would allow to locally adjust the white balance, for example to warm up shadows, or to deal with mixed scene lighting such as “daylight” and “tungsten”. This module needs to be inserted just after “demosaic”.&lt;br /&gt;
&lt;br /&gt;
====Auto White balance====&lt;br /&gt;
The “White balance” module (in the “autowblocal” branch) serves two purposes:&lt;br /&gt;
* allowing a local adjustment of the white balance (of course)&lt;br /&gt;
* testing new algorithms for automatic white balance adjustment:&lt;br /&gt;
** in general use (full image), in order to achieve better results than with the current algorithm. Of course one will tell me that I should create a specific branch for “White balance”, but here I’m trying to hit two targets with one bullet.&lt;br /&gt;
&lt;br /&gt;
As a reminder, I’ve been asked in 2012 and 2013 to develop an iterative white balance “Auto Robust WB[http://ieeexplore.ieee.org/document/1649677/]”. At that time, another developer and I had spent a lot of time on this for an unsatisfactory result, so we gave up. Since then, benefiting from this experience, I resumed this work but in the reverse way! Now, if I’m correct, the algorithm works. I took advantage of this new capability (currently working on raw images only) to search in the academic literature for other auto WB algorithms. I found, and developed two new algorithms:&lt;br /&gt;
* “auto edge”[https://www.researchgate.net/publication/301419990_A_Method_to_Improve_Robustness_of_the_Gray_World_Algorithm]: the idea is to create an accentuation mask allowing to reinforce parts of the image where details are more prevalent, compared to flatter regions.&lt;br /&gt;
* “auto standard deviation”[http://www.acad.bg/rismim/itc/sub/archiv/Paper3_1_2012.pdf]: here, the image (or part of it for the local control) is divided in 12 zones, for each of which mean and standard deviation are computed, and the result assembled.&lt;br /&gt;
A third algorithm, “Color by correlation”[https://courses.cs.washington.edu/courses/cse467/08au/labs/l5/whiteBalance.pdf], looks promising but I’m facing several difficulties. After many trials of many types, the results are just too erratic…&lt;br /&gt;
&lt;br /&gt;
I also added the notion of gamma:&lt;br /&gt;
* the same principles which deal with luminance distribution – gamma sRGB – used in the main RawTherapee code.&lt;br /&gt;
&lt;br /&gt;
Bear in mind that the automatic white balancing is a totally non deterministic mathematical problem. The algorithms may perform more or less well (and faster or slower), but a perfect result can’t exist! Why is it so? If one is referring to the principles of color management ([http://rawpedia.rawtherapee.com/Color_Management_addon/fr#Balance_des_blancs]), it is necessary to have knowledge of the three of: the coloured object, the illuminant and the observer. At least two of those are unknown in practice. In addition, the environment in which an image is shot is not known while it has an effect on the perception (CIECAM), and the same is true during both image editing and viewing. The mission is thus almost impossible!&lt;br /&gt;
&lt;br /&gt;
The aim of the “White balance” module is '''for testing the algorithms''', there are 7 of them at least, and twice that number if “gamma sRGB” is considered. Indeed, in order to circumvent the obstacles encountered five years ago, instead of the using the image before demosaicing, I used the image just after demosaicing, allowing to apply (or not) “gamma sRGB”, ending in the same conditions as in normal use (but without normal “White balance” and “ICC or DCP” profile).&lt;br /&gt;
&lt;br /&gt;
Ideally, we should test the algorithms on many images, as well: which algorithm(s) to keep and implement in normal – global RGB – mode (maybe one or two, in addition to the current algorithm which we should keep for compatibility).&lt;br /&gt;
&lt;br /&gt;
====Local control of White balance====&lt;br /&gt;
The local control is currently limited to 1 spot only, but there’s no difficulty to increase this if users want so… while waiting for the evolution of “locallab”.&lt;br /&gt;
&lt;br /&gt;
Of course, I hear voices say “it doesn’t work”, or “the output doesn’t match with the preview”. But it does work! And it is more than evident that matching exactly the preview is by definition almost impossible… (differences between shadows, sun light, different illuminants, etc…) whatever the relevance of the algorithm.&lt;br /&gt;
&lt;br /&gt;
==What are the challenges we need to solve?==&lt;br /&gt;
Several general issues need to be solved so as to achieve smoothness in use:&lt;br /&gt;
* allow an (almost) unlimited number of RT-spots (the name we chose for the control spots in RawTherapee);&lt;br /&gt;
* adapt the local algorithms to be aware of scale, because many of them take the image size – the treated area – into account. This aspect is fundamental, particularly with curves which act on the whole image;&lt;br /&gt;
* minimise memory use and computation time for JPG and TIFF output;&lt;br /&gt;
* allow easy updates in case of evolution of either the algorithms or the number of methods/modules;&lt;br /&gt;
* optimise (minimise) the differences between the preview and the output.&lt;br /&gt;
* etc…&lt;br /&gt;
&lt;br /&gt;
For each RT-spot:&lt;br /&gt;
* allow for the action to occur, on user choice, either inside or outside (“Inverse” mode) of the selection area;&lt;br /&gt;
* allow shape detection, on user choice, in order to limit the action based on features/shapes;&lt;br /&gt;
* take care of the transition between the center of the treated area and the other parts of the image;&lt;br /&gt;
* etc…&lt;br /&gt;
&lt;br /&gt;
Currently, RT-spots are operational in Lab mode with the following modules and methods:&lt;br /&gt;
# “Colour and Light”: “Lightness”, “Chrominance”, “Contrast” in normal mode with 4 curves L=f(L), L=f(H), C=f(C), H=f(H), and in “inverse” mode;&lt;br /&gt;
# “Exposure”: normal mode only;&lt;br /&gt;
# “Vibrance:” normal mode only;&lt;br /&gt;
# “Blur &amp;amp; noise”: normal and “inverse” modes;&lt;br /&gt;
# “Retinex”: normal and “inverse” modes, now also with “transmission gain” curve;&lt;br /&gt;
# “Sharpening”: normal and “inverse” modes;&lt;br /&gt;
# “Contrast by detail levels” (CBDL): normal mode only;&lt;br /&gt;
# “Denoise”: normal mode only.&lt;br /&gt;
&lt;br /&gt;
==General principles==&lt;br /&gt;
===The RT-spot object===&lt;br /&gt;
As I mentioned earlier, the system used in RT is similar to the one developed in Nik Software, but with some significant differences:&lt;br /&gt;
* each RT-spot can be viewed as an object with a number of fields (about 70 as of today), made of sliders, curves, control points, etc…;&lt;br /&gt;
* each field, grouped in modules, can be activated or not, and have different parameter values according to their nature;&lt;br /&gt;
* the modules are made to be coherent for the user: “Color and Light”, “Exposure”, “Contrast”, “Vibrance”, “Blur”, “Retinex”, “Sharpening”, “Tone Mapping”, “Contrast by detail levels”, “Denoise”;&lt;br /&gt;
* the number of RT-spot objects can vary from 2 up to 500;&lt;br /&gt;
* data describing the RT-spot objects are stored in text files with .mip extension;&lt;br /&gt;
* creating, modifying and tracking of the RT-spot objects are done in a “for” loop;&lt;br /&gt;
* there’s no code duplication.&lt;br /&gt;
&lt;br /&gt;
===Partitioning into 4 zones – previewing the RT-spot area===&lt;br /&gt;
When the user selects an RT-spot, the screen preview shows:&lt;br /&gt;
* a centre, made of a circle whose diameter and position can be adjusted directly using the mouse or the sliders;&lt;br /&gt;
* two horizontal and two vertical handles, whose position can be modified directly using the mouse or the provided sliders, controlling the extent of the area affected by the RT-spot;&lt;br /&gt;
* if &amp;quot;Show spot delimiters&amp;quot; is checked in &amp;quot;Preferences&amp;quot; &amp;gt; &amp;quot;General&amp;quot; tab &amp;gt; &amp;quot;Local adjustments&amp;quot;, one can visualise approximately the area affected by the spot. Because I couldn’t work cleanly with the « arc/ellipse/scale » function in the Cairo graphics library, I made each quadrant defined by a pseudo-ellipse made of 3 Bézier curves joining each other. In most cases the approximation is satisfying… To help grabbing the 4 handles, I made them longer (the Bézier curves are inactive!).&lt;br /&gt;
&lt;br /&gt;
We obtain 4 zones, whose orientation can be modified (the default rotation angle is set to zero). Those 4 zones have each of their vertices connected by imaginary ellipses.&lt;br /&gt;
&lt;br /&gt;
It is possible to drag the handles outside the image preview area.&lt;br /&gt;
&lt;br /&gt;
It should be possible to replace the ellipse with a hand drawn curve (even if I think its usefulness is debatable because of the existence of the shape detection algorithm), as long as the homothetic transform of the curve doesn’t intersect with the original curve. Although the benefits from this intellectually satisfying “improvement” should negligible in the case of the RT-spots, it will be possible to make the current RT-spots and lasso type of controls coexist eventually.&lt;br /&gt;
&lt;br /&gt;
===Tint, chroma, luminance references and the algorithm principle in “normal” mode===&lt;br /&gt;
In order to develop an efficient shape detection algorithm:&lt;br /&gt;
* The central circle zone is used as the reference. Based on the diameter value chosen by the user, the algorithm computes the tint (hue), chroma and luminance averages.&lt;br /&gt;
* The choice of the central zone diameter depends on the use intent. For example, if working on a foliage area the user would benefit from choosing a smaller diameter value in order to select only the foliage green; in contrast, for skin tones the user should increase the diameter to avoid the detection of parasites (noise, eye lashes…).&lt;br /&gt;
* For each quadrant, depending on the the value of the “Scope” slider, the algorithm does:&lt;br /&gt;
# take into account the tint difference between the zone centre and the affected pixel;&lt;br /&gt;
# through a complex algorithm based on the deltaE notion (perceived difference between two colours, taking tint, chroma and luminance into account), decrease the amount of applied effect as a function of the difference between the central zone and the affected pixel;&lt;br /&gt;
# follow either a linear or a parabolic law to adjust the amount of applied effect, based on the specific the case.&lt;br /&gt;
&lt;br /&gt;
This allows adapting the amount of effect according to the above-mentioned criteria. For example, if the central circle is located on foliage, the action will be limited to the leaves, without touching the background (which would be impossible to obtain with the lasso type of controls). Additionally, if some other foliage resides within the area covered by the RT-spot, it will also be affected.&lt;br /&gt;
* Adjusting the value of the “Transition” slider modifies the transition of the effect (from the centre to the edge): on 50, the inner (linear) half will get the full 100% action/effect, while the effect in the outer half will gradually transition from 100% to 0% towards the edge;&lt;br /&gt;
* By increasing the value of “Scope”, progressively more of the selected area is taken into account, whatever the tint, chroma and luminance;&lt;br /&gt;
* Conversely, by decreasing the “Scope” value the effect will get limited to the pixels which are more similar (in terms of deltaE) to the reference zone.&lt;br /&gt;
&lt;br /&gt;
The shape detection algorithm works in “Normal” mode except for some modules (“Denoise”). It’s not implemented in “Inverse” mode, doing so would not make sense.&lt;br /&gt;
&lt;br /&gt;
The algorithm will see its performance increase when the user chooses “Enhanced” or “Enhanced + chroma denoise” in the “Global quality:” combobox. The second choice additionally applies a low amount of chroma noise reduction in order to get rid of artefacts which could be brought up by the “Enhanced” algorithm (note that the chroma denoise step increases memory use and computing time).&lt;br /&gt;
&lt;br /&gt;
The algorithm is used in full capacity for “scope” &amp;lt; 20.&lt;br /&gt;
&lt;br /&gt;
===Why no alternative algorithms?===&lt;br /&gt;
It should be possible to implement other shape detection algorithms than the deltaE-based one used currently, for example:&lt;br /&gt;
* edge detection algorithms such as “Canny” or “Sobel”;&lt;br /&gt;
* wavelet decomposition.&lt;br /&gt;
&lt;br /&gt;
But in both cases, everything would have to be done!&lt;br /&gt;
&lt;br /&gt;
===Functioning in “inverse” mode===&lt;br /&gt;
When it is available, the “Inverse” mode is extremely simplified: only the “Transition” slider can be used to apply the effect.&lt;br /&gt;
As of late October 2017, I devised a new method for “Inverse” mode. It is limited to the “Blur &amp;amp; Noise” module (see the corresponding section below).&lt;br /&gt;
&lt;br /&gt;
===Maximum number of RT-spots===&lt;br /&gt;
By default the number of available RT-spots is 8. You can choose any number between 2 and 499. For this you only need to change the parameter “Nspot” in the “options” file (for example: Nspot=12). Restart RawTherapee for the modification to be taken into account.&lt;br /&gt;
&lt;br /&gt;
===The “super” algorithm===&lt;br /&gt;
The key to “success” was the algorithm implemented in late January 2017, which works this way:&lt;br /&gt;
# on the pixel data which are within the area covered by the RT-spot, the algorithm applies either a “traditional” curve, a slider, or a normal transfer function (“Retinex”, “Tone Mapping”, “Contrast by detail levels”, “Vibrance”, …);&lt;br /&gt;
# the LUT or the transfer function is converted into an equivalent of a slider, separating negative and positive values so that the function can be viewed as multiple sliders (as many sliders as there are pixels) in the -100, 0, +100 interval;&lt;br /&gt;
# the data are passed to the shape detection function – the 4 quadrants. For every pixel, the difference in terms of tint, chroma and luma is computed with regards to the central reference. The linear variation equations are estimated for luminance (L=f(L)), chroma (C=f(C)) or transfer functions;&lt;br /&gt;
# different corrections are applied to account for the environment (sky, skin tones…)&lt;br /&gt;
# a correction is made (with threshold and iterations) in order to avoid correcting (or only slightly, based on the user’s choice) the grey or neutral tones which are in the same tint as the reference (but with a low chroma value);&lt;br /&gt;
# the parameters are weighted based on the shape of the RT-spot (ellipses) and the transition zone;&lt;br /&gt;
# the values of the “Global quality:” parameters are important, particularly so for images with a low amount of noise – chroma noise is interpreted by the algorithm being of the same colour as the spot. It is thus necessary to suppress this noise, that is the purpose of “Enhanced + chroma denoise” (this algorithm may not be sufficient, though – in this case using the local “Denoise” module may be useful).&lt;br /&gt;
&lt;br /&gt;
This new (“super”) algorithm seems to perform generally well, but in the event when the RT-spot is located in a grey/neutral or flat area, the algorithm may fail. In such cases, using the old algorithm is recommended (except for “Retinex”, “Tone Mapping” and “Contrast by detail levels” for which it is made unavailable for the sake of code simplicity).&lt;br /&gt;
&lt;br /&gt;
===Artefact reduction and the “Global quality” algorithms===&lt;br /&gt;
By default, “Global quality:” is set to “Enhanced + chroma denoise”. Whereas it increases computation time, it is still generally preferable. In case one wants a more responsive preview, “Enhance” or “Standard” can be chosen (good for exploring the image).&lt;br /&gt;
* two sliders allow reducing artefacts and improving the algorithm’s rendering. They work based on chroma, in neutral/gray tones. To completely remove its effect, one can simply set “iterations=0”. These sliders may be used for &amp;quot;Color light&amp;quot;, &amp;quot;Exposure&amp;quot;, &amp;quot;Retinex&amp;quot;, &amp;quot;Vibrance&amp;quot;, &amp;quot;Tone mapping&amp;quot; and &amp;quot;Contrast by detail levels&amp;quot;;&lt;br /&gt;
* for (even slightly) noisy images, the algorithms may be misled. In this case it is recommended to keep &amp;quot;Global quality:”  set to “Enhanced + chroma denoise&amp;quot;, and (sometimes) activate the local “Denoise” module and adjust the sliders very gently (including “Luminance”);&lt;br /&gt;
* under some circumstances, with “Tone Mapping” for example, the artefact reduction algorithm may actually generate more artefacts. When it happens, set “iterations=0”.&lt;br /&gt;
&lt;br /&gt;
If your images are generally clean (no or very low noise), you can choose to have “Standard” as the default for “Global quality:” – this will speed up the image processing. To do so, go to “Preferences” &amp;gt; “Performance and quality” tab &amp;gt; “Local adjustments” and choose the “Standard” algorithm among the 3 options. This will become the new default  when new RT-spots are created, but of course the algorithm can still be changed on the fly by choosing from the “Global quality” combo box.&lt;br /&gt;
&lt;br /&gt;
===Avoid color shift===&lt;br /&gt;
The “Avoid color shift” checkbox serves two purposes:&lt;br /&gt;
* put the colours within the current working profile gamut, using a relative colorimetry;&lt;br /&gt;
* adjust colours using a “Munsell” correction – particularly for red-orange and blue-purple colours, when saturation in the L*a*b* space has changed significantly.&lt;br /&gt;
&lt;br /&gt;
===“mip” files – Principles of the multi-point algorithm===&lt;br /&gt;
For the local control system to work and keep track of RT-spot objects, a text file – similar to a pp3 – is written in 2 possible places:&lt;br /&gt;
* next to the edited image file. If, for example, you edit an image named ASC4509.NEF, a new file named ASC4509.NEF.mip will be generated in the same folder. In this case, several sessions can be open for the same image, as long as copies of the image are stored in different folders. However, the folder names in the path have to contain ASCII characters only, otherwise it will make the program crash;&lt;br /&gt;
* in the dedicated “mip” folder, within the “cache” directory (through an MD5 hash number which identifies the file). This is the default. If chosen, when multiple copies of the same file exist in distinct folders, editing them creates as many “mip” files. This option allows the use of non ASCII characters in the folder names and path.&lt;br /&gt;
&lt;br /&gt;
The choice between these two behaviours is made in “Preferences” &amp;gt; “Image processing” tab &amp;gt; “Mip profiles”.&lt;br /&gt;
&lt;br /&gt;
The “mip” files contain the data which are passed to RawTherapee through processes of the “procparams” type, and LUTs which allow editing in zoom mode. When updating RawTherapee to a new version, it may be required to delete the “mip” files (or the whole cache) to avoid a potential crash of the application. This can be achieved by going to “Preferences” &amp;gt; “File browser” tab, then choosing “Clear mip” and/or “Clear pp3” – all this is valid only if “mip” and “pp3” files have been set to be saved to the cache folder, otherwise they will have to be manually deleted from the working folder. Keeping older “mip” and “pp3” files may lead to instability or crashes of the application.&lt;br /&gt;
&lt;br /&gt;
====Architecture of the filter====&lt;br /&gt;
When I “ventured” into a multi-point, no-layer and no-mask system, code duplication had to be avoided. Indeed, it is unthinkable to consider, for 10 RT-spots, generating 10 GUI code blocks, and just as many code blocks in “rtengine”. After careful consideration, the idea was to have a file updating and tracking in real time – i.e. a file which would follow each modification made by the user – the actions/modifications history.&lt;br /&gt;
&lt;br /&gt;
Of course, the parameters used by RawTherapee for the GUI and for the main code through “params” are of different types:&lt;br /&gt;
* numeric: integer, float, double,…&lt;br /&gt;
* Boolean&lt;br /&gt;
* string (in choice menus for the different modules)&lt;br /&gt;
* curves, through “vectors” of type double with dynamic dimension&lt;br /&gt;
* …&lt;br /&gt;
&lt;br /&gt;
====Data conversion====&lt;br /&gt;
In order to simplify data management, the first step is to convert all data to integers. Sometimes this can lead to a slight precision loss, which I think is negligible.&lt;br /&gt;
* This operation is very simple for numeric values, even though in some cases (such as hue, which is expressed in radian in the interval [-Pi, +Pi]) it needs a double “float*100 and /100 conversion to keep precision.&lt;br /&gt;
* It is logical for Boolean operations and methods.&lt;br /&gt;
* However, it is a complex matter regarding curves. The values to be recorded in the “mip” file are of type vector&amp;lt;double&amp;gt;, in a dynamic table of numeric values. There may be a simpler way, by using existing functions from “procparams”, but I didn’t succeed. &lt;br /&gt;
Nevertheless, I could get around this by:&lt;br /&gt;
# converting doubles to integers with 3 significant figures – which is largely enough,&lt;br /&gt;
# then converting the “vector” to a variable length character string,&lt;br /&gt;
# the writing and reading of this character string and converting to a vector dynamically using an appropriate function (”strcurv_data”). Note that this function allows adjusting the curves within the limit of 16 inflection points (Bézier curve) for the flat curve, and 32 points for the diagonal, which should be enough. Whether this would not be enough, it should be possible to increase that number, though compatibility would be compromised.&lt;br /&gt;
&lt;br /&gt;
====Some elements about curves====&lt;br /&gt;
The implementation of curves has been a complex task, particularly since:&lt;br /&gt;
# each curve needs its own reset function – resize() at each iteration,&lt;br /&gt;
# which implies oddities regarding their description, for example the diagonal curve gets initialised with several points, despite it looks being “empty”. This is mandatory for correct functioning, but this means that the curve is always open/active. Consequently, to avoid some unwanted loss of computation time in “preview” mode, the user has to activate the curve by clicking on the “curves” combobox. The same activation is necessary for L=f(H) and C=f(C) curves. While clicking enabling the “curves” (linear) would seem to be a better solution, it didn’t work despite many trials.&lt;br /&gt;
# during all the procedure, we need to set each &amp;quot;params&amp;quot; value to &amp;quot;clear&amp;quot; for curves, for each LUT, at each iteration and then through a &amp;quot;vector&amp;quot; to reassign the good, updated values to &amp;quot;curve params&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
====Data storing and dynamic use====&lt;br /&gt;
Once data have been converted:&lt;br /&gt;
* they are stored in a text (mip) file,&lt;br /&gt;
* each one is referenced inside a 2-dimension dynamical table:&lt;br /&gt;
# dataspot[x][y] for numeric and boolean values and methods, where “x” is the representative index of the parameter (e.g. “9” is for “lightness”) and “y” represents the current RT-spot (control spot). Value “0” represents the current in-use value (the one stores in “params”).&lt;br /&gt;
# retistr[y], llstr[y], lhstr[y], ccstr[y], hhstr[y], skinstr[y], pthstr[y], exstr[y] for parameters of type “curve”. Currently there are only 8 parameters, used for local “Retinex”, “Color and light” (L=f(L), C=f(C), L=f(H), H=F(H)), “Vibrance” and “Exposure”, but it is easy to add more. “y” is used as above in 1.&lt;br /&gt;
&lt;br /&gt;
The way data are stored and used fits well with improccoordinator.cc (current management / preview) and simpleprocess.cc (TIFF / JPG  output) files, but not so with dcrop.cc and the partial display of the image (RawTherapee’s pipeline).&lt;br /&gt;
&lt;br /&gt;
In this case (zoom / preview) another solution had to be found in order to synchronise the modifications in real time. I made use of LUTs, so that to each entry referenced in the table described above a LUTi(z) is associated, with z=500 possible entries (500 corresponds to the current maximum number of RT-spots, but this limit can be decreased or increased). The LUTi “z” corresponds to the dataspot “y”. A 25,000 entries LUTi (arbitrary number) is used for “retistr”, “llstr”, “lhstr”, “ccstr”, “hhstr”, “skinstr”, “pthstr”, “exstr” for storing each “vector” curve value in memory (up to 69 values stored as integers).&lt;br /&gt;
&lt;br /&gt;
During data processing, exchanges occur between: params, dynamic tables and LUTi. The values used by dcrop.cc are dynamically linked to dynamical tables by parent→.&lt;br /&gt;
&lt;br /&gt;
====Exchange processes and dynamic data storing====&lt;br /&gt;
# reading of the “mip” file to check the version number and guide the updates&lt;br /&gt;
# creating the “mip” file if it doesn’t exist&lt;br /&gt;
# storing the data in LUTi and dynamic tables from the values stored in “params” (index 0 values)&lt;br /&gt;
# first interactive update with the GUI through a transfer function between “rtengine” and locallab.cc (aloListener → localretChanged). This is one of the 3 functions required for the process to work correctly&lt;br /&gt;
# reading of the “mip” file and data storing in dynamic tables (index values ==&amp;gt; y) according to the number of RT-spots&lt;br /&gt;
# creating a loop – according to the number of RT-spots – which updates LUTi (required by “dcrop”) and “params” values from values stored in the dynamic tables&lt;br /&gt;
# call to the “Lab_local” function which contains the algorithms controlling each RT-spot (luminance, sharpness, retinex, denoise, …)&lt;br /&gt;
# second interactive update with the GUI through another transfer function between “rtengine” and “locallab.cc”&lt;br /&gt;
# treatment of the current RT-spot by using the index (0) values from the dynamic tables. These values are attributed to 1) “params”, 2) LUTi and 3) current index values&lt;br /&gt;
# call to the “Lab_local” function for the current RT-spots&lt;br /&gt;
# saving to the “mip” file.&lt;br /&gt;
&lt;br /&gt;
Note that if the user modifies the curve (amplitude, number of inflection points) a third interactive update is made in order to conform all of the data according to events.&lt;br /&gt;
&lt;br /&gt;
====A few unavoidable “fantasies”====&lt;br /&gt;
Of course everything looks simple, the process works if, and only if, all the data are dynamically updated. I’ve tried a lot, went groping, and finally found a working solution… but an uncanny one. There’s probably a more “informatically” correct way to do it, but at this point I’ve done as explained above and hereafter.&lt;br /&gt;
&lt;br /&gt;
The 3 exchanges between “rtengine” and the GUI occur with 3 parameters which actually do nothing in the program except doing the update process:&lt;br /&gt;
# “anbspot” which takes values of 0 or 1&lt;br /&gt;
# “cTgainshaperab” (curve) which takes any value bewteen 0.70 and 0.90&lt;br /&gt;
# “retrab” which varies around 500.&lt;br /&gt;
I have added 3 more parameters (in the form of sliders) – hueref, chromaref and lumaref – hidden from the user but which are used to update the system in real time, to correctly take into account the reference “spot” values. Allowing those 3 parameters to vary brings stability and allows real time updates. Increasing the number of those “fantasy” parameters should not be necessary. These extra parameters are hidden to the user, and are only visible in the history.&lt;br /&gt;
&lt;br /&gt;
In addition, I had to add some empirical time delays, giving time to time… Time delay is used for example when the user modifies the curve (amplitude, number of inflection points).&lt;br /&gt;
&lt;br /&gt;
==Specificity of the local mode (as compared to “Lab adjustments”)==&lt;br /&gt;
Hereafter is some useful information for the user, often specific to the local mode.&lt;br /&gt;
&lt;br /&gt;
===Color and Light===&lt;br /&gt;
 * The algorithms used for luminance and contrast in local mode differ from the ones used in “Lab adjustments”, which may lead to differences in rendering.&lt;br /&gt;
* The luminance algorithm is made such that below -90 and down to -100 for “Lightness”, it is possible to increase the image's “darkness”, almost to the point of getting a luminance value close to 0. To accentuate this effect, “Chrominance” can be decreased and “Scope” increased.&lt;br /&gt;
* The inverse mode can be used for creating graduated frames. If “Ligthness” is set to -100 and &amp;quot;Chrominance&amp;quot; is reduced, the “frame border” will be black.&lt;br /&gt;
* For the “Lightness” and “Contrast” sliders, the user can choose among 2 algorithms: the first one (default) is close to that in “Lab adjustments” while the second one, activated through “Lightness - Contrast ‘Super’” is close to the algorithm used for the L=f(L) “Super” curve.&lt;br /&gt;
* Do not hesitate, when needed, to activate “Enhanced” or “Enhanced + chroma denoise” in the “Global Quality:” combobox.&lt;br /&gt;
&lt;br /&gt;
====Curves====&lt;br /&gt;
* An L=f(L) or C=f(C) curves allow controlling the luminance and chrominance for each RT-spot as a function of luminance or chrominance.&lt;br /&gt;
* An L=f(H) curve allows controlling the luminance for each RT-spot as a function of tint.&lt;br /&gt;
* An H=f(H) curve allows controlling the tint for each RT-spot as a function of tint.&lt;br /&gt;
The curves are activated by selecting one of the two algorithms from the “Curves types” combobox:&lt;br /&gt;
* “Normal”: the curves – particularly the one that is the most difficult to manage, L=f(L) – use an algorithm close to the one used with the sliders (Normal mode),&lt;br /&gt;
* “Super”: using a new algorithm, which I think performs very well (it even surprised me the first time I used it).&lt;br /&gt;
&lt;br /&gt;
Caution: when the RT-spot resides in an area which is neutral, grey or very uniform, the artefacts introduced by the new algorithm (“Super” algorithm for the curve or the slider) may be impossible to get rid of. Use one of the 2 older algorithms to avoid that.&lt;br /&gt;
&lt;br /&gt;
===Exposure===&lt;br /&gt;
The “Exposure” module may look like the the one in global RGB mode, but:&lt;br /&gt;
* it works entirely in L*a*b* mode, hence the differences in rendering;&lt;br /&gt;
* there’s no “Lightness”, “Chroma” or “Contrast” slider, whose functions are already fulfilled in the “Color and Light” module;&lt;br /&gt;
* there’s only one “Contrast” curve, similar to the L=f(L) firm “Color and Light”. Of course its effect is different from “Tone curve” which works in RGB mode. If needed, two L=f(L) curves can be activated, one under “Color and Light” and the other under “Exposure”.&lt;br /&gt;
&lt;br /&gt;
===Vibrance===&lt;br /&gt;
This module is similar to the main one (from RawTherapee's &amp;quot;Exposure&amp;quot; tab).&lt;br /&gt;
&lt;br /&gt;
===Blur &amp;amp; Noise===&lt;br /&gt;
“Blur” is activated only when “Radius” =&amp;lt; 2.&lt;br /&gt;
By significantly lowering the default value of “Scope” and possibly checking “Blur luminance only”, it is possible to get a different amount of blur for the different tints.&lt;br /&gt;
Since October 2017, 3 methods are proposed:&lt;br /&gt;
* “Normal”: the shape detection algorithm has been improved, it is now closer to shape detection algorithm proposed in the other modules;&lt;br /&gt;
* “Inverse”: a simplified algorithm, which doesn’t make use of “Scope”. The inversion is coarse and doesn’t allow a fine separation between the affected and unaffected areas;&lt;br /&gt;
* “Symmetric”: this new algorithm uses the same processes as “Normal”, and adjusting “Scope” the user can target the process with more precision.&lt;br /&gt;
Caution: &lt;br /&gt;
* Using the “Inverse” mode will blur large portions of the image, which can not be corrected later on.&lt;br /&gt;
* The action of “Scope” may sometimes appear puzzling: for instance, in a portrait, the eyes (which of course differ from the skin) may be blurred if the value of “Scope” is too low.&lt;br /&gt;
&lt;br /&gt;
===Tone Mapping===&lt;br /&gt;
Caution when uniformly coloured areas (sky, grey/neutral zones) have a similar tint to the area on which the RT-spot is placed. In cases where this leads to artefacts, set the “Iterations” slider to 0 in “Settings” &amp;gt; “Reduce artefacts – Improve algorithm”.&lt;br /&gt;
&lt;br /&gt;
===Retinex===&lt;br /&gt;
Compared to the standard “Retinex” module, the local “Retinex module has simplified controls, and is applied at the end of the pipeline instead of the beginning. Since “mip” version 10002, the “Transmission gain” is specific to each RT-spot.&lt;br /&gt;
&lt;br /&gt;
===Sharpening===&lt;br /&gt;
Only the “RL Deconvolution” algorithm is provided here.&lt;br /&gt;
&lt;br /&gt;
===Contrast by detail levels===&lt;br /&gt;
Compared to the main RGB mode module, this one has:&lt;br /&gt;
* 5 levels instead of 6,&lt;br /&gt;
* no slider for “skin tone” protection (not needed since the algorithm works locally on the RT-spot area),&lt;br /&gt;
* an additional “Chroma” slider.&lt;br /&gt;
&lt;br /&gt;
Caution when uniformly coloured areas (sky, grey/neutral zones) have a similar tint to the area on which the RT-spot is placed. In cases where this leads to artefacts, set the “Iterations” slider to 0 in “Settings” &amp;gt; “Reduce artefacts – Improve algorithm”.&lt;br /&gt;
&lt;br /&gt;
===Denoise===&lt;br /&gt;
Compared to the main RGB mode module, this one has:&lt;br /&gt;
* only the wavelet tool working (no Fourier function, nor medians),&lt;br /&gt;
* less sliders and curves,&lt;br /&gt;
* the possibility to work differentially on fine or coarse noise for both luminance and chrominance noise.&lt;br /&gt;
&lt;br /&gt;
==A specific use case : reduction of image defects (dirty sensor, red eyes, …)==&lt;br /&gt;
“Locallab” had not been thought with the idea of correcting small image defects. However, some visible, “photographically disturbing” defects may actually be tamed or even removed. Of course, this is not incompatible with other more specialised modules which could be introduced (or not) into “Locallab”… At least 3 existing modules can serve this purpose, alone or in combination, by adapting their use:&lt;br /&gt;
* “Color and Light” for spot-like defects;&lt;br /&gt;
* “Contrast by detail levels” for spread out defects;&lt;br /&gt;
* “Blur and Noise” as an optional complement (caution, this is a destructive action, use moderately).&lt;br /&gt;
&lt;br /&gt;
These modules can be used either on the main image (raw, TIFF,  …) or on a flat-field image.&lt;br /&gt;
&lt;br /&gt;
===Using the “Color and Light” module===&lt;br /&gt;
* Activate “Color and Light”&lt;br /&gt;
* A red eye removal tool equivalent can be obtained by framing closely around the eye – central circle zone centered on the eye’s red, spot handles close to the eye – low “Scope” value, then lowering “Lightness” and “Chrominance” to -100.&lt;br /&gt;
* The same idea allows reducing the “IR spot” kind of defect by framing closely around the defect – central circle zone centred on the defect, spot handles close to the defect area – then lowering “Chrominance” to taste, and if needed lowering the “scope” value.&lt;br /&gt;
* In some (simple) situations, a “dirty sensor” defect can be reduced, in particular in the case of “sensor grease”. It can be seen as stains or spots on a uniform background. To attenuate this, choose a tight framing of around the defect – central circle on the centre of the defect (adapt the size of the RT-spot), drag the handles so that they are not too close to the border of the defect (this will make the transition less noticeable). Then: a) decrease “Transition” towards lower values; b) check “Lightness - Contrast “Super”; c) adjust “Lightness” and “Chrominance” as needed to bring the defect area closer to the unaffected area; d) if needed adjust slightly “Scope” to achieve the best result.&lt;br /&gt;
&lt;br /&gt;
===Using the “Contrast by detail levels” module===&lt;br /&gt;
When the sensor is dirty (grease), and when the affected area is large or if there are multiple small defects, “Contrast by detail levels” may be used, working as a sort of “wavelet” tool on luminance, and if needed on chrominance. In such cases: a) place the RT-spot on one of the stronger defects (adjust the size as needed); b) drag the handles so as to cover most of the affected area; c) set “Transition” to higher value; d) activate “Contrast by detail levels” and decrease the contrast of levels 3 and 4 (or lower); you can adjust the “Chroma” slider if needed.&lt;br /&gt;
&lt;br /&gt;
==Settings in the Preferences dialog==&lt;br /&gt;
Below is a list of the settings (already mentioned above in several places) which can be accessed from the “Preferences” dialog:&lt;br /&gt;
* In “Preferences” &amp;gt; “General” tab &amp;gt; “Local adjustments”, by checking the “Show spot delimiters” checkbox, an approximate zone delimitation is drawn which helps viewing the area affected by the RT-spot and its settings.&lt;br /&gt;
* If your images generally have low noise, you can set the default for “Global quality” to “Standard”, and get a significant speedup in processing time. This setting is found under “Preferences” &amp;gt; “Performance &amp;amp; Quality” tab &amp;gt; “Local adjustments”. The three choices for quality are selected from the “Local adjustments Quality method” combobox. Default is “Enhanced + chroma denoise”.&lt;br /&gt;
* Regarding “mip” files:&lt;br /&gt;
** the choice for “mip” files destination folder is set from “Preferences” &amp;gt; “Image processing” tab &amp;gt; “Mip Profiles”;&lt;br /&gt;
** in order to clean the generated “mip” profiles, go to “Preferences” &amp;gt; “File Browser” tab &amp;gt; “Cache Options” and click on the “Clear mip” button and/or “Clear pp3” – this is valid in the case where you chose to store “mip” files in the cache, otherwise if you chose to let RT write the “mip” files next to the input file, you will have to delete them manually. Note that the presence of older versions of “mip” and “pp3” files may lead to instability or even crashes of RawTherapee.&lt;br /&gt;
&lt;br /&gt;
==Processing time and memory use==&lt;br /&gt;
At image export time (output to JPG, TIFF…), for the “normal” mode, the algorithms compute the data only for in the RT-spot delimited areas, not for the whole image. Thus, processing time and memory stay reasonable. Note that of course, this will depend on the number of RT-spots, their size, and the type(s) of treatment done in these RT-spots.&lt;br /&gt;
&lt;br /&gt;
Excluding “Denoise” and “Sharpen”, processing time is in the order of a few tenths of a second per RT-spot, and memory use of a few hundred MB.&lt;br /&gt;
&lt;br /&gt;
Two settings have a strong influence on resource use:&lt;br /&gt;
    • “Denoise” which adds around 1 sec. of processing time, and 1 MB of memory use;&lt;br /&gt;
    • “Global quality: Enhanced + chroma denoise” which adds around 0.5 sec. And 0.6 MB.&lt;br /&gt;
These figures depend on the size of the RT-spot.&lt;br /&gt;
&lt;br /&gt;
==Future evolution==&lt;br /&gt;
Besides usual tweaking, bug corrections, improvements (settings, user interface)… it would be desirable to improve the GUI with regards to the creation/selection/modification of individual RT-spots.&lt;br /&gt;
&lt;br /&gt;
From a programming point of view, it should be possible to improve code readability and maintainability, and to integrate all the “mip” files code parts (as done in “rgbproc.cc”) which currently are linearly integrated to void procedures in “improccoordinator.cc”, “dcrop.cc” and “simpleprocess.cc”.&lt;/div&gt;</summary>
		<author><name>Sguyader</name></author>
	</entry>
	<entry>
		<id>http://rawpedia.rawtherapee.com/index.php?title=Local_Adjustments/fr&amp;diff=3296</id>
		<title>Local Adjustments/fr</title>
		<link rel="alternate" type="text/html" href="http://rawpedia.rawtherapee.com/index.php?title=Local_Adjustments/fr&amp;diff=3296"/>
		<updated>2017-10-26T17:13:04Z</updated>

		<summary type="html">&lt;p&gt;Sguyader: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Quel type de contrôle local? ==&lt;br /&gt;
Lorsqu'on observe les différents logiciels du marché on trouve plusieurs types de contrôles locaux&lt;br /&gt;
# les contrôles de type &amp;quot;lasso&amp;quot;, associés à des calques et masques de fusion, comme par exemple dans Photoshop (c). Ce type de contrôle est majoritaire dans les logiciels (Photoshop, Gimp, Darktable...) et l'avis des utilisateurs est obligatoirement orienté vers ceux-ci au détriment du point 3) ci-dessous moins connu!&lt;br /&gt;
# les dispositifs de suppression de &amp;quot;yeux rouges&amp;quot;, ou de &amp;quot;spot&amp;quot; liés aux imperfections du capteur&lt;br /&gt;
# les contrôles de type U-points, utilisés jusque récemment dans Nikon Capture NX2 (c), ou comme complément à d'autres logiciels comme Nik Software (c). Pour qui a tâté de ces dispositifs (rares maintenant) il n'est pas question de revenir aux calques et masques de fusion! Ce type de contrôle nécessite un apprentissage différent de ceux de type lasso-calque et un désapprentissage cognitif de ceux-ci. De mon point de vue, ils sont globalement plus performants.&lt;br /&gt;
&lt;br /&gt;
Dans la version présente de Rawtherapee, l’algorithme développé est proche dans le principe du point 3) ci-dessus, les U-points. Bien sûr, le code de Nik Software est inconnu, mais il y a quelques années j'ai été séduit par la facilité d'utilisation et les performances des U-points, et j'ai entrepris de développer un produit qui ne ferait pas appel, ni au lasso, ni aux calques, ni aux masques de fusion.&lt;br /&gt;
&lt;br /&gt;
Bien sûr rien n'interdit d'avoir les 3 possibilités (Lasso-calque, retouches spot, U-points) !&lt;br /&gt;
&lt;br /&gt;
La version actuelle est très certainement perfectible, au niveau de l'interface graphique - GUI - notamment:&lt;br /&gt;
* pour le suivi et repérage des RT-spot (spot de contrôle) à l'écran&lt;br /&gt;
* pour les réglages des différents curseurs qui gagneraient à être intégrés au spot de contrôle, comme le fait Nik Software (c).&lt;br /&gt;
Cependant, ces deux points n'affectent pas ni l’utilisation courante, ni la portabilité.&lt;br /&gt;
&lt;br /&gt;
J'ai ajouté, pour faciliter l'utilisation et éviter les menus trop longs en mode écran, une interface GUI similaire à celle de Wavelet, avec des &amp;quot;expanders&amp;quot;.&lt;br /&gt;
Vous avez ainsi la possibilité pour chaque famille d'action (color and light, Blur, Retinex, etc.):&lt;br /&gt;
# faire apparaître ou non le détail des commandes : curseurs, méthodes, courbes,..&lt;br /&gt;
# activer ou non l'ensemble des fonctions de la famille d'action.&lt;br /&gt;
Attention, le choix - 2 - active ou annule l'ensemble des RT-spot ( spot de contrôle); il est théoriquement possible d'associer cette possibilité à chaque RT-spot, mais quel intérêt ? &lt;br /&gt;
&lt;br /&gt;
===Contrôles locaux Lab et RGB===&lt;br /&gt;
* Les premiers algorithmes sont écrits en mode L*a*b* avec les contrôles suivants : &amp;quot;Color and Light&amp;quot;, &amp;quot;Blurr addnoise&amp;quot;, &amp;quot;Retinex&amp;quot;, &amp;quot;Tone mapping&amp;quot;, &amp;quot;Sharpen&amp;quot;, &amp;quot;CBDL&amp;quot;, &amp;quot;Denoise&amp;quot;..Deux contrôles suivants ont été ajoutés : &amp;quot;Exposure&amp;quot;, &amp;quot;Vibrance&amp;quot;...&lt;br /&gt;
* Voir ci-dessous le principe des algorithmes, mais un des points clefs à retenir pour la détection de forme et la prévention des artefacts est que le mode Lab préserve la teinte &amp;quot;hue&amp;quot;, qui joue un rôle déterminant.&lt;br /&gt;
* L'idée d'un module &amp;quot;RGB&amp;quot; vient évidemment à l'esprit, avec ''a minima'' un module :&lt;br /&gt;
** White Balance : qui permettrait une retouche de la balance des blancs par exemple pour &amp;quot;réchauffer les parties à l'ombre&amp;quot;, ou permettre le mélange de deux éclairages par exemple &amp;quot;lumière du jour&amp;quot; et &amp;quot;Tungsten&amp;quot;. Ce module doit être placé juste après &amp;quot;demosaic&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
====White balance auto====&lt;br /&gt;
Le module &amp;quot;white balance&amp;quot; (branche &amp;quot;autowblocal&amp;quot;) vise deux objectifs :&lt;br /&gt;
* permettre la retouche locale de la Balance des blancs (évident!)&lt;br /&gt;
* tester de nouveaux algorithmes de Balance des blancs automatique :&lt;br /&gt;
** en usage général (full image), afin d'obtenir de meilleurs résultats que l'algorithme actuel. Bien sûr on va me rétorquer qu'il faudrait une branche spécifique &amp;quot;White balance&amp;quot;, mais j'essaie de faire d'une pierre deux coups.&lt;br /&gt;
&lt;br /&gt;
Pour mémoire en 2012 et 2013, il m'avait été demandé, de mettre en place la balance des blancs itérative &amp;quot;Auto Robust WB[http://ieeexplore.ieee.org/document/1649677/]&amp;quot;. A l'époque avec un autre développeur nous avons passé beaucoup de temps pour un résultat assez peu satisfaisant... d'où l'abandon. Depuis, fort de cette expérience j'ai repris le travail mais à l'envers ! Maintenant - si je ne me suis pas trompé - l'algorithme fonctionne.&lt;br /&gt;
J'ai profité de cette possibilité (actuellement uniquement pour des images RAW), pour rechercher dans la littérature universitaire, d'autres algorithmes auto. J'ai trouvé et mis au point deux nouveaux algorithmes :&lt;br /&gt;
* &amp;quot;auto edge[https://www.researchgate.net/publication/301419990_A_Method_to_Improve_Robustness_of_the_Gray_World_Algorithm]&amp;quot; : l'idée ici est de créer un masque d’accentuation pour permettre de renforcer les parties de l'images où il y a des détails par rapport aux aplats.&lt;br /&gt;
* &amp;quot;auto standard deviation[http://www.acad.bg/rismim/itc/sub/archiv/Paper3_1_2012.pdf]&amp;quot; : l'image (ou la partie d'image pour le mode local) est divisée en 12 zones. Pour chacune on calcule moyenne et écarts type, puis on assemble le résultat.&lt;br /&gt;
Un troisième algorithme semble prometteur &amp;quot;Color by correlation[https://courses.cs.washington.edu/courses/cse467/08au/labs/l5/whiteBalance.pdf]&amp;quot;, mais je me heurte à quelques difficultés...Après beaucoup de tests en tous genres, les résultats sont erratiques...&lt;br /&gt;
&lt;br /&gt;
J'ai ajouté la notion de gamma:&lt;br /&gt;
* les mêmes principes concernant la répartition de la luminance - gamma sRGB - utilisé dans le code de Rawtherapee&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A titre de rappel, la balance des blancs automatique est un problème mathématique totalement indéterminé. Il est possible d'avoir des algorithmes plus ou moins performants (et aussi plus ou moins rapides ou lents), mais en aucun cas le résultat sera parfait ! Pourquoi est-ce impossible ? Si on se réfère aux principes de la gestion des couleurs [[http://rawpedia.rawtherapee.com/Color_Management_addon/fr#Balance_des_blancs]], il est nécessaire de connaitre à la fois l'objet coloré, l'illuminant et l'observateur. Il y a au moins 2 familles d'inconnues. De plus l'environnement de prise de vue n'est pas connu et influe sur la perception (CIECAM) ainsi que l'environnement de traitement et de visualisation. Donc, mission quasi impossible !&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
L'objectif du module '''&amp;quot;White balance&amp;quot; est de tester les algorithmes''', au total il y en a 7 et le double (au moins) si on prend en compte le &amp;quot;gamma sRGB&amp;quot;. En effet pour contourner les obstacles d'il y a 5 ans, j'ai utilisé au lieu de l'image avant demosaic, l'image juste après demosaic, sur laquelle on peut ou non appliquer le &amp;quot;gamma sRGB&amp;quot;, pour se retrouver dans les mêmes conditions qu'en usage normal (sinon bien sûr sans &amp;quot;White Balance&amp;quot; et sans profil &amp;quot;ICC ou DCP&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
L'idéal est de tester sur de nombreuses images les divers algorithmes &amp;quot;auto&amp;quot; avec un objectif : quel(s) algorithme(s) retenir et implanter en mode &amp;quot;full image&amp;quot; (peut être 1 ou 2 en plus de l'actuel qu'il faut garder pour compatibilité).&lt;br /&gt;
&lt;br /&gt;
====White balance contrôle local====&lt;br /&gt;
Le contrôle local est actuellement limité à 1 spot, mais pas de difficultés si les utilisateurs le souhaitent d’accroitre...En attendant les évolutions de &amp;quot;locallab&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Bien sûr il me sera dit &amp;quot;cela ne fonctionne pas&amp;quot;, ou &amp;quot;on ne se raccorde pas avec le 'preview'&amp;quot;. Cela fonctionne ! Et il est plus qu'évident que atteindre le preview est par définition quasi impossible... (différences ombres , soleil, illuminants différents, etc.) en dehors de la pertinence de l'algorithme.&lt;br /&gt;
&lt;br /&gt;
Vous disposez de 3 sliders : temperature, tint, blue/red equalizer&lt;br /&gt;
&lt;br /&gt;
== Quels défis à résoudre? ==&lt;br /&gt;
Plusieurs problèmes généraux sont à résoudre afin d'obtenir un fonctionnement fluide :&lt;br /&gt;
* permettre un nombre quasi illimité de RT-spot (spot de contrôles);&lt;br /&gt;
* adapter les algorithmes locaux aux problèmes d'échelle, car beaucoup d'algorithmes tiennent compte de la taille de l'image - donc de la zone traitée. Cet aspect est fondamental, notamment avec les courbes qui agissent sur toute l'image;&lt;br /&gt;
* minimiser l'occupation mémoire et les temps de traitement en sortie JPG et TIF;&lt;br /&gt;
* permettre des mises à jour logicielles faciles en cas d’évolution des algorithmes ou d'évolution du nombre de méthodes ;&lt;br /&gt;
* optimiser les écarts entre &amp;quot;preview&amp;quot; et sortie JPG / TIF; &lt;br /&gt;
* etc.&lt;br /&gt;
&lt;br /&gt;
Pour chaque RT-spot :&lt;br /&gt;
* permettre selon le cas, une action dans la zone sélectionnée ou à l'extérieur de la zone sélectionnée;&lt;br /&gt;
* permettre selon le cas une détection de forme pour délimiter l'action;&lt;br /&gt;
* assurer une transition entre le cœur de la zone traitée et le reste de l'image;&lt;br /&gt;
* etc.&lt;br /&gt;
&lt;br /&gt;
Actuellement, les RT-spot (spot de contrôles) sont opérationnels, pour le mode Lab, et pour les méthodes suivantes:&lt;br /&gt;
# Color and light : lightness, chrominance, contraste en mode normal avec quatre courbes L=f(L), L=f(H), C=f(C), H=f(H) et inverse ;&lt;br /&gt;
# Exposure : en mode normal&lt;br /&gt;
# Vibrance : en mode normal&lt;br /&gt;
# Blur and Noise : en mode normal et inverse;&lt;br /&gt;
# Retinex : en mode normal et inverse, maintenant avec gestion de la courbe &amp;quot;transmission gain&amp;quot;;&lt;br /&gt;
# Sharpening : en mode normal et inverse;&lt;br /&gt;
# Contrast By Detail Levels : en mode normal;&lt;br /&gt;
# Denoise : en mode normal.&lt;br /&gt;
&lt;br /&gt;
== Principes généraux ==&lt;br /&gt;
===L'Objet RT-spot===&lt;br /&gt;
Comme je l'ai évoqué, le système utilisé est proche de celui mis au point par Nik Software, avec de grandes différences :&lt;br /&gt;
* chaque RT-spot, peut être considéré comme un objet qui comporte plusieurs champ - à ce jour environ 70, constitués de curseurs, courbes;&lt;br /&gt;
* chaque champ, regroupé en paquets  peut être ou non activé, et peut avoir des valeurs variables selon sa nature ;&lt;br /&gt;
* les paquets sont des ensembles cohérents pour l'utilisateur : color &amp;amp; light, exposure, contrast, vibrance, blurr, retinex, sharpening, tone-mapping, contrast by detail level, denoise ;&lt;br /&gt;
* le nombre de &amp;quot;RT-spots objets&amp;quot; peut varier de 2 à 500 ;&lt;br /&gt;
* les données des &amp;quot;RT-spots objets&amp;quot; sont stockées dans un fichier texte &amp;quot;mip&amp;quot;;&lt;br /&gt;
* les &amp;quot;RT-spots objets&amp;quot; sont gérés - création, modification, suivi - dans une boucle &amp;quot;for&amp;quot;;&lt;br /&gt;
* il n'y a pas de duplication de code.&lt;br /&gt;
&lt;br /&gt;
===Le découpage en quatre zones - l’aperçu de la zone RT-spot===&lt;br /&gt;
Lorsque l’utilisateur sélectionne un RT-spot (spot de contrôle),l’image à l’écran montre:&lt;br /&gt;
* un centre, constitué d'un cercle dont on peut faire varier : a) le diamètre, b) la position avec la souris ou les curseurs;&lt;br /&gt;
* quatre lignes horizontales ou verticales dont on peut faire varier les positions avec la souris ou les curseurs.&lt;br /&gt;
* si vous sélectionnez en &amp;quot;Preferences&amp;quot; / &amp;quot;General&amp;quot; / &amp;quot;Local adjustements&amp;quot;, en cochant la case &amp;quot;Show spot delimiters&amp;quot;, vous obtiendrez une approximation de la zone concernée par le spot et ses réglages. Attention, je ne suis pas arrivé à un travail propre avec la fonction &amp;quot;arc / ellipse / scale&amp;quot; de la bibliothèque graphique Cairo; j'ai donc opté pour chaque &amp;quot;quart&amp;quot; à une pseudo ellipse obtenue par 3 courbes de Bézier se raccordant entre elles. Dans la majorité des cas l'approximation est satisfaisante...Pour permettre une sélection plus facile j'ai été amené à accroître la taille des 4 lignes horizontales et verticales qui sélectionnent la taille du spot (les courbes de Bézier sont inactives!).&lt;br /&gt;
&lt;br /&gt;
On aboutit à 4 zones, dont on ne peut faire varier l'orientation (angle d'inclinaison obligatoirement à zéro).&lt;br /&gt;
Ces 4 zones ont chacun de leurs sommets reliés par une ellipse imaginaire. &lt;br /&gt;
&lt;br /&gt;
Il est possible de pointer les limites des zones en dehors de la zone &amp;quot;preview&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
A terme, il doit être possible, même si l'utilité me semble discutable du fait de l'algorithme de détection de forme, de remplacer l'ellipse, par une courbe tracée à l'aide de la souris, à condition que la transformée homothétique de la courbe n'ait pas d'intersection avec la courbe originale. Cette &amp;quot;amélioration&amp;quot; intellectuellement satisfaisante, ne devrait être que d'un apport négligeable - dans le cas des U-points. Néanmoins il sera toujours possible de faire coexister les actuels U-points avec des contrôles par&amp;quot;lasso&amp;quot; de type Photoshop (c).&lt;br /&gt;
&lt;br /&gt;
===Les références teinte, chroma, luminance et le principe de l'algorithme en mode &amp;quot;normal&amp;quot;===&lt;br /&gt;
Afin de mettre en œuvre un algorithme performant de détection de forme :&lt;br /&gt;
* la zone du cercle central, sert de référence. En fonction du diamètre choisi par l'utilisateur, le système calcule, la moyenne de la teinte (hue), de la chroma, et de la luminance.&lt;br /&gt;
* le choix du diamètre de la zone centrale dépend de l'usage. Par exemple pour un feuillage, l'utilisateur aura intérêt à choisir une valeur faible afin de ne sélectionner que le vert du feuillage; à l'inverse pour la peau l'utilisateur aura intérêt  à accroître le diamètre afin d'éviter les prises en compte de données parasites (bruit, cils, etc.).&lt;br /&gt;
* pour chaque quart, et en fonction du curseur &amp;quot;scope&amp;quot;, le système prend en compte :&lt;br /&gt;
# en premier lieu de l'écart de teinte entre la zone centrale et le pixel courant ;&lt;br /&gt;
# puis, un algorithme complexe, s'appuyant sur la notion de deltaE (différence perçue entre 2 couleurs prenant en compte, la teinte, la chroma et la luminance), atténue l'action en fonction de l'écart entre la zone centrale et le pixel courant.&lt;br /&gt;
# la modification d'action utilise soit une loi linéaire, soit une loi parabolique selon le cas.&lt;br /&gt;
&lt;br /&gt;
Ceci va permettre de différencier l'action selon les critères énoncés ci-dessus, comme par exemple, si le cercle central se trouve dans un feuillage, de limiter l'action à l'ensemble du feuillage sans toucher à l'arrière plan (ce qui est impossible avec un lasso). De plus si un autre feuillage se situe dans la zone couverte, celui-ci sera également concernés par la modification.&lt;br /&gt;
&lt;br /&gt;
* l'action sur le curseur transition va permettre de faire varier l'action : si le curseur est réglé sur 50, la moitié (linéaire) de la zone concernée verra une application à 100% de l'effet, puis une transition agira régressivement jusqu'aux limites de la zone.&lt;br /&gt;
* si on accroît la valeur de &amp;quot;scope&amp;quot;, progressivement l’ensemble de la zone sélectionnée est prise en compte quelque soit la couleur, la chroma et la luminance. &lt;br /&gt;
* si on réduit la valeur de &amp;quot;scope&amp;quot;,l'action se limitera aux pixels très proches (en termes de deltaE) de la zone de référence.&lt;br /&gt;
&lt;br /&gt;
L'algorithme de détection de forme est opérationnel en mode &amp;quot;normal&amp;quot; sauf pour certains modules (denoise) - son implantation en mode inverse n'a pas de sens.&lt;br /&gt;
&lt;br /&gt;
Cet algorithme va avoir ses performances accrues, si l'utilisateur choisit : &amp;quot;Quality Enhanced&amp;quot; ou &amp;quot;Qualty enhanced + chroma denoise&amp;quot;. Ce second choix apporte une très légère réduction du bruit de chroma afin de supprimer les artefacts possibles liés à l'utilisation de &amp;quot;enhanced&amp;quot; (à noter dans le cas + chroma denoise, un accroissement des besoins en mémoire et du temps de traitement).&lt;br /&gt;
&lt;br /&gt;
L'algorithme utilise toutes ses capacités, si les valeurs de &amp;quot;scope&amp;quot; sont inférieures à 20.&lt;br /&gt;
&lt;br /&gt;
===Pourquoi pas d'autres algorithmes? ===&lt;br /&gt;
Remarque : il doit être possible de programmer d'autres algorithmes de détection de forme que celui ci-dessus fondé sur les différences de deltaE. &lt;br /&gt;
&lt;br /&gt;
* Par exemple les algorithmes de détection de bords (edge) tels que &amp;quot;Canny&amp;quot; ou &amp;quot;Sobel&amp;quot;;&lt;br /&gt;
* Ou encore le principe de décomposition en ondelettes.&lt;br /&gt;
Mais dans ces 2 cas tout reste à faire !&lt;br /&gt;
&lt;br /&gt;
===Le fonctionnement en mode inverse===&lt;br /&gt;
Lorsqu'il est proposé, le fonctionnement en mode inverse est extrêmement simplifié, seul le curseur &amp;quot;transition&amp;quot; permet de moduler l'action.&lt;br /&gt;
&lt;br /&gt;
A partir de fin octobre 2017, j'ai mis au point une autre manière de concevoir le mode &amp;quot;inverse&amp;quot;. Cette manière est limitée à l'outil &amp;quot;Blur and Noise&amp;quot; (voir ce paragraphe)&lt;br /&gt;
&lt;br /&gt;
===Nombre maximum de RT-spot (spot de contrôle)===&lt;br /&gt;
Par défaut le nombre de RT-spot est de 8.&lt;br /&gt;
Vous pouvez choisir n'importe quelle valeur entre 2 et 499. Pour cela il suffit de changer la variable Nspot dans le fichier &amp;quot;option&amp;quot;; par exemple Nspot=12.&lt;br /&gt;
Il est indispensable de relancer Rawtherapee après cette modification.&lt;br /&gt;
&lt;br /&gt;
===L'algorithme 'super'===&lt;br /&gt;
La clef du &amp;quot;succès&amp;quot; (si on peut utiliser ce terme) tient à l'algorithme présent depuis fin janvier 2017. je vais l'expliciter de manière simplifiée :&lt;br /&gt;
# pour la partie des données concernées par la zone sélectionnée, on applique une fonction courbe &amp;quot;traditionnelle&amp;quot; ou un curseur classique, ou la fonction de transfert normale (Retinex, Tone mapping, CBDL, Vibrance, ...);&lt;br /&gt;
# puis on réalise une conversion de la LUT ou de la fonction de transfert , en un équivalent &amp;quot;slider&amp;quot;, en séparant les valeurs positives et négatives, afin d'avoir une représentation de la fonction comme une multitude de &amp;quot;sliders&amp;quot; (autant qu'il y a de pixels concernés) dans l'intervalle -100, 0, +100&lt;br /&gt;
# on passe ces données à la fonction de reconnaissance de forme - celle des 4 zones. On détecte pour chaque pixel l'écart de teinte, chroma et luma par rapport à la référence. On établit des équations de variations linéaire selon le cas de la luminance (L = f(L)) ou de la chroma (C=f(C) ou des fonctions de transfert).&lt;br /&gt;
# puis on applique diverses corrections pour tenir compte de l'environnement, ciel, peau,...&lt;br /&gt;
# enfin, on applique une correction (avec seuil et itérations)pour ne pas corriger (ou le faire faiblement selon le choix de l'utilisateur), les tons gris ou neutres qui sont dans la même teinte que la référence (mais avec une chroma faible).&lt;br /&gt;
# ces paramètres sont ensuite pondérés en fonction, de la forme (ellipse) et de la zone de transition.&lt;br /&gt;
# bien sûr les réglages des paramètres qualité &amp;quot;Global quality&amp;quot;, ont leur importance, notamment dans les images légèrement bruitées - le bruit chromatique est considéré par l'algorithme comme de la même couleur que le spot. Il faut donc avoir la possibilité de le supprimer, d'où la sélection &amp;quot;enhanced + chroma denoise&amp;quot; (il est possible que ce réglage soit insuffisant, agir en conséquence sur &amp;quot;Denoise local&amp;quot; si nécessaire).&lt;br /&gt;
&lt;br /&gt;
Cet algorithme nouveau ('super') semble généralement fonctionner, mais dans le cas où le spot est sur une zone gris - neutre ou l'action sur des zones à faible gradient, l'algorithme peut être pris en défaut, dans ce cas utiliser l'ancien (quand c'est possible !!), car pour Retinex, Tone Mapping, CBDL je n'ai pas offert ce choix par souci de simplification)&lt;br /&gt;
&lt;br /&gt;
===Réduction des artefacts et l'algorithme &amp;quot;Global quality&amp;quot;===&lt;br /&gt;
Par défaut, &amp;quot;Global quality&amp;quot; est à &amp;quot;Enhanced + chroma denoise&amp;quot;. Certes cela augmente les temps de traitements, mais globalement c'est préférable. Vous pouvez, si vous trouvez les temps de rafraichissement long, choisir &amp;quot;enhance&amp;quot; ou &amp;quot;standard&amp;quot; et examiner l'image...&lt;br /&gt;
* 2 curseurs permettent de réduire les artefacts et améliorer le rendu de l'algorithme. Ils agissent en fonction de la chroma, dans les tons gris neutres. Pour désactiver complètement l'effet il suffit de mettre &amp;quot;iterations = 0&amp;quot;. Ces curseurs permettent, d'une part de réduire les artefacts et,  d'autre part d'agir sur le rendu de l'image. L'action est possible pour &amp;quot;Color Light&amp;quot;, &amp;quot;Exposure&amp;quot;, &amp;quot;Retinex&amp;quot;, &amp;quot;Vibrance&amp;quot;, &amp;quot;Tone Mapping&amp;quot; et &amp;quot;Contrast by details levels&amp;quot;.&lt;br /&gt;
* lorsque les images sont bruitées, même légèrement (beaucoup d’images sont bruitées sans que cela soit gênant par exemple les ciels, les nuages,...), les algorithmes sont &amp;quot;trompés&amp;quot;, ne pas hésiter à laisser activé &amp;quot;Global quality = enhanced + chroma denoise&amp;quot; et (quelquefois) activer &amp;quot;denoise local&amp;quot; et agir très légèrement sur les curseurs (y compris luminance). &lt;br /&gt;
* dans certaines circonstances, par exemple avec Tone-mapping, le système de réduction d'artefacts peut générer des artefacts. Dans ce cas, mettre le slider &amp;quot;iterations&amp;quot; à 0.&lt;br /&gt;
&lt;br /&gt;
Vous pouvez choisir la valeur par défaut de &amp;quot;Global Quality&amp;quot;, par exemple si vos images sont très peu bruitées, et ainsi réduire notablement les temps de traitement.&lt;br /&gt;
Pour cela, aller dans &amp;quot;Preferences&amp;quot;, &amp;quot;Performance and Quality&amp;quot;, &amp;quot;Local adjustements&amp;quot; et choisir entre Les 3 propositions. C'est ce choix qui sera proposé par défaut à l'utilisateur pour chaque nouveau &amp;quot;Spot&amp;quot;, bien sûr il est possible ensuite de modifier ce choix, en sélectionnant la combo-box &amp;quot;Global Quality&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===Avoid color shift===&lt;br /&gt;
Cette case à cocher vise deux objectifs :&lt;br /&gt;
* mettre les couleurs dans le gamut de l'espace de travail courant (working profile) en utilisant une colorimétrie relative ;&lt;br /&gt;
* ajuster les couleurs à l'aide d'une correction &amp;quot;Munsell&amp;quot; - notamment les rouges-orangés et les bleus-pourpres, lorsque la saturation dans le domaine L*a*b* a évolué notablement.&lt;br /&gt;
&lt;br /&gt;
===Les fichiers *.mip - les principes de l’algorithme multipoints=== &lt;br /&gt;
Afin de permettre le fonctionnement - enregistrement des valeurs pour chaque spot de contrôle - un fichier de type texte, assez proche des fichiers pp3 est enregistré à deux endroits possibles :&lt;br /&gt;
* à côté du fichier à traiter. Si par exemple vous traitez le fichier ASC4509.NEF, un fichier ASC4509.NEF.mip sera enregistré dans le même dossier. Si vous choisissez cet emplacement, vous pourrez ouvrir plusieurs sessions pour un même fichier image, si celui-ci est présent dans des dossiers différents. Par contre, le nom des dossiers et du &amp;quot;path&amp;quot; doit obligatoirement n'avoir que des caractères ASCII...sinon plantage. &lt;br /&gt;
* dans le dossier &amp;quot;mip&amp;quot;, à l'intérieur du dossier &amp;quot;cache&amp;quot; (via un &amp;quot;hash number MD5&amp;quot; qui identifie le fichier). Valeur par défaut. Si vous choisissez cet emplacement, si le fichier image est présent dans plusieurs dossiers, il y aura plusieurs fichiers mip. Cette option permet d'utiliser des dossiers et &amp;quot;path&amp;quot; avec des caractères NON ASCII.&lt;br /&gt;
* le choix entre ces emplacements est possible à partir de : Preferences / Image processing / Mip Profiles&lt;br /&gt;
 &lt;br /&gt;
Ce fichier mip contient les données qui seront ensuite passées au programme, via d'une part les processus de type &amp;quot;procparams&amp;quot; et d'autre part des LUT qui permettent le fonctionnement en mode zoom.&lt;br /&gt;
Lors de la mise à jour d'une nouvelle version, il pourra dans certains cas être demandé d'effacer les fichiers *.mip (voire le cache)  afin d'éviter un crash. Pour cela vous pouvez aller dans &amp;quot;Preferences&amp;quot; / &amp;quot;Files browser&amp;quot;, puis &amp;quot;Clear mip&amp;quot; et / ou &amp;quot;clear pp3&amp;quot; - si bien sûr vous avez positionné &amp;quot;mip&amp;quot; et &amp;quot;pp3&amp;quot; dans le cache, sinon il faudra exécuter cette opération manuellement dans le dossier courant. La présence d'anciennes versions de fichiers &amp;quot;mip&amp;quot; ou de &amp;quot;pp3&amp;quot; peut amener de l'instabilité voire un crash du système. &lt;br /&gt;
&lt;br /&gt;
====Architecture du système====&lt;br /&gt;
Lorsque je me suis &amp;quot;aventuré&amp;quot; vers la possibilité d'un système multipoints sans calques, sans masques,...il était obligatoire de refuser de dupliquer le code. Comment envisager par exemple pour 10 spot de contrôles, 10 codes GUI, et autant de code dans Rtengine.&lt;br /&gt;
Après réflexion, l’idée est venue d'avoir un fichier mis à jour en temps réel - c'est à dire qui suit les modifications faites par l'utilisateur - de l’historique des actions / modifications.&lt;br /&gt;
&lt;br /&gt;
Bien sûr, les variables utilisées par Rawtherapee, au niveau de l'interface GUI, et par la suite dans l'ensemble du code via &amp;quot;params&amp;quot;, sont de type divers:&lt;br /&gt;
* numériques : entier, float,  double,...&lt;br /&gt;
* booléenne&lt;br /&gt;
* choix (menus pour &amp;quot;méthodes&amp;quot;) de type string&lt;br /&gt;
* courbes via des &amp;quot;vectors&amp;quot; de type double a dimension dynamique.&lt;br /&gt;
* ...&lt;br /&gt;
&lt;br /&gt;
====Conversion des données====&lt;br /&gt;
La première étape - afin de simplifier ensuite la gestion des données - est de convertir toutes ces données en entiers. Dans quelques cas cela peut aboutir à une très légère perte de précision, qui de mon point de vue est tout à fait négligeable.&lt;br /&gt;
*Cette opération est très simple pour les valeurs numériques, même si elle peut aboutir dans certains cas (la teinte  - Hue - s'exprime en radians dans l’intervalle -Pi + Pi) par une double transformation &amp;quot;float * 100 et / 100&amp;quot; pour garder la précision.&lt;br /&gt;
*Elle est logique pour les opérations booléennes et les méthodes.&lt;br /&gt;
*Par contre elle s'est avérée complexe pour les courbes. Les valeurs à stocker dans le fichier texte sont de type vector&amp;lt;double&amp;gt; soit un tableau dynamique de valeurs numériques. Probablement il doit y avoir un moyen &amp;quot;plus simple&amp;quot; en utilisant les fonctions qui sont utilisées dans &amp;quot;Procparams&amp;quot;, mais je ne suis pas arrivé à les mettre en œuvre. J'ai contourné l'obstacle en :&lt;br /&gt;
#transformant les valeurs doubles en entier avec 3 chiffres significatifs - ce qui est largement suffisant&lt;br /&gt;
#puis en convertissant le &amp;quot;vector&amp;quot; en une chaine de caractère de longueur variable&lt;br /&gt;
#la lecture et l'écriture de cette chaine et sa conversion en &amp;quot;vector&amp;quot; se faisant dynamiquement par une fonction appropriée (&amp;quot;strcurv_data&amp;quot;). A noter que cette fonction permet de modifier des courbes jusqu'à une limite de 16 points d'inflexion (Courbe de Beziers) pour la courbe plate, et 32 pour la diagonale, ce qui devrait être suffisant. Si c'était insuffisant (??) il est possible (via une perte de compatibilité) d'accroître ce nombre.&lt;br /&gt;
&lt;br /&gt;
====Quelques éléments sur les courbes====&lt;br /&gt;
L'implémentation des courbes a été complexe, au delà de ce qui est écrit ci-dessus, notamment :&lt;br /&gt;
# chaque courbe doit obligatoirement avoir une fonction reset - resize() à chaque itération;&lt;br /&gt;
# ce qui implique des curiosités au niveau de leur description, par exemple la courbe diagonale est initialisée avec plusieurs points, alors qu'elle a l'air &amp;quot;vide&amp;quot;. C'est indispensable au bon fonctionnement. Mais ceci a pour conséquence que cette courbe est toujours ouverte / active. Donc cela implique si on veut éviter des consommations de temps en mode &amp;quot;preview&amp;quot; que l'utilisateur &amp;quot;active&amp;quot; la courbe en activant la combobox &amp;quot;curves&amp;quot;. Cette même activation est aussi nécessaire pour les courbes L=f(H) et C=f(C). Bien sûr, on se serait tenté de penser qu'il suffit d'activer le mode &amp;quot;enabled&amp;quot; de la fonction &amp;quot;courbes&amp;quot; (linéaire), mais après de nombreux essais cette démarche est infructueuse!&lt;br /&gt;
# tout au long des procédures, il est obligatoire de mettre &amp;quot;clear&amp;quot; chaque valeur de &amp;quot;params&amp;quot; pour les courbes, chaque LUT, pour chaque itération et ensuite via &amp;quot;vector&amp;quot; de réattribuer les bonnes valeurs courantes à &amp;quot;params courbe&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
====Stockage et utilisation dynamique des données====&lt;br /&gt;
Une fois les données converties :&lt;br /&gt;
* elles sont stockées dans un fichier texte&lt;br /&gt;
* chacune est référencée dans un tableau dynamique à deux dimensions : &lt;br /&gt;
# dataspot[x][y], pour les valeurs numériques, booléenne et les méthodes,   où 'x' représente l'indice représentatif de la variable, par exemple '9' correspond à 'Lightness', et 'y' représente le RT-spot (spot de contrôle) courant. La valeur '0' représente la valeur courante en cours d'utilisation (celle stockée dans 'params&amp;quot;). &lt;br /&gt;
# retistr[y], llstr[y], lhstr[y], ccstr[y], hhstr[y], skinstr[y], pthstr[y], exstr[y] pour les variables de type &amp;quot;curve&amp;quot; (aujourd'hui il n'y a que 8 variables celle utilisée dans &amp;quot;Retinex&amp;quot; local, et celles dans &amp;quot;Color and light&amp;quot; (L=f(L), C=f(C), L=f(H), H=F(H))et  &amp;quot;vibrance&amp;quot; et &amp;quot;exposure&amp;quot;,  mais il est assez facile d'en ajouter), avec 'y' comme ci-dessus.&lt;br /&gt;
&lt;br /&gt;
Ce stockage et utilisation - nous reviendrons plus loin sur l'algorithme lecture / écriture dynamique - convient aisément pour le fichier Improccoordinator.cc (support de la gestion courante - Preview) et Simpleprocess.cc (sortie TIF / JPG), mais ne peut convenir, pour Dcrop.cc et la vision partielle de l'image (les fameux pipeline de Rawtherapee).&lt;br /&gt;
&lt;br /&gt;
Pour ce cas (zoom - Preview) il a fallu imaginer autre chose, qui assure en temps réel la synchronisation des modifications. J'ai utilisé des LUT, dans le cas actuel, à chaque donnée référencée dans les tableaux ci dessus est associé une LUTi(z), avec z=500 entrées possibles (500 correspond à la limite informatique du nombre de RT-spot (spots de contrôles)...qu'on peut très facilement accroitre ou réduire). 'z' pour les LUTi correspond à 'y' pour dataspot. Une LUTi avec 25000 (arbitraire) entrées est utilisée  pour &amp;quot;retistr&amp;quot;, &amp;quot;llstr&amp;quot;, &amp;quot;lhstr&amp;quot;, &amp;quot;ccstr&amp;quot;, &amp;quot;hhstr&amp;quot;, &amp;quot;skinstr&amp;quot;, &amp;quot;pthstr&amp;quot;, &amp;quot;exstr&amp;quot; pour garder en mémoire (sous forme d'un entier) chaque valeur du 'Vector' de la courbe (il peut y en avoir jusque 69).&lt;br /&gt;
 &lt;br /&gt;
Au cours du traitement, des échanges sont réalisés entre: params, les tableaux dynamiques et les LUTi. Les valeurs utilisées par Dcrop.cc sont liées dynamiquement aux tableaux dynamiques par parent-&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
====Processus d'échanges et stockage des données dynamiques ====&lt;br /&gt;
Sans entrer dans une description fastidieuse, je resterais aux principes généraux :&lt;br /&gt;
# lecture du fichier &amp;quot;mip&amp;quot; pour lire la version et orienter  les mises à jour&lt;br /&gt;
# première écriture du fichier &amp;quot;mip&amp;quot; s'il n'existe pas&lt;br /&gt;
# stockage des données dans les LUTi et les tableaux dynamiques à partir des valeurs stockées dans &amp;quot;Params&amp;quot; (valeurs index 0)&lt;br /&gt;
# première mise à jour interactive avec le GUI via une fonction de transfert entre Rtengine et locallab.cc (aloListener-&amp;gt;localretChanged). Cette fonction fait partie des 3 nécessaires pour obtenir un fonctionnement correct.&lt;br /&gt;
# lecture du fichier texte &amp;quot;mip&amp;quot; et stockage des données dans les tableaux dynamiques (valeurs index ==&amp;gt; y) - selon le nombre de RT-spot (spots de contrôle)&lt;br /&gt;
# Création d'une boucle - selon le nombre de RT-spot (spots de contrôle)- où à partir des valeurs stockées dans les variables tableaux dynamique, les LUTi (nécessaires à Dcrop) et les valeurs de Params sont actualisées.&lt;br /&gt;
# Appel de la fonction &amp;quot;Lab_local&amp;quot; qui contient les algorithmes de contrôle de chaque RT-spot (luminance, Sharp, retinex, denoise, etc.)  &lt;br /&gt;
# deuxième mise à jour interactive avec le GUI via une autre fonction de transfert entre Rtengine et locallab.cc &lt;br /&gt;
# puis traitement du RT-spot (spot de contrôle) courant, en récupérant les valeurs index (0) des tableaux dynamiques. Ces valeurs sont attribuées à : 1) params, 2) LUTi, 3) valeurs index en cours&lt;br /&gt;
# Appel de la fonction &amp;quot;Lab_local&amp;quot; pour le RT-spot courant.&lt;br /&gt;
# sauvegarde du fichier &amp;quot;mip&amp;quot;&lt;br /&gt;
&lt;br /&gt;
A noter que si l'utilisateur, modifie une courbe, amplitude ou nombre de points d'inflexion, une troisième mise à jour interactive est réalisée pour mettre en conformité l’ensemble des données en fonction des événements.&lt;br /&gt;
&lt;br /&gt;
====Quelques fantaisies incontournables====&lt;br /&gt;
Bien sûr, tout à l'air simple, mais le système ne fonctionne que, si et seulement si, toutes les données sont dynamiquement mises à jour.&lt;br /&gt;
&lt;br /&gt;
J'ai beaucoup essayé, tâtonné, pour aboutir à une solution qui fonctionne...certes curieuse; il y a probablement un moyen plus &amp;quot;informatique&amp;quot; de traiter cela, mais à ce stade, j'ai fait comme décrit ci-dessus et ci-après.&lt;br /&gt;
&lt;br /&gt;
Les 3 échanges entre Rtengine et le GUI se font notamment avec 3 variables qui ne servent à rien dans le programme - sinon à mettre à jour:&lt;br /&gt;
# &amp;quot;anbspot&amp;quot; qui prend les valeurs forcées 0 ou 1&lt;br /&gt;
# &amp;quot;cTgainshaperab&amp;quot; (curve), dont je fais osciller une valeur entre 0.70 et 0.90&lt;br /&gt;
# &amp;quot;retrab&amp;quot; qui oscille autour de 500.&lt;br /&gt;
&lt;br /&gt;
J'ai ajouté 3 variables (sous forme de &amp;quot;sliders&amp;quot;) - hueref, chromaref, lumaref, totalement invisibles à l'utilisateur, mais qui servent à rafraichir le système en temps réel, pour permettre la bonne prise en compte des valeurs &amp;quot;spot&amp;quot; de référence.  &lt;br /&gt;
&lt;br /&gt;
Les appels aux changements de ces 3 variables amènent la stabilité au système et une mise à jour en temps réel.&lt;br /&gt;
Il ne devrait pas être nécessaire d’accroitre le nombre de ces variables &amp;quot;fantaisistes&amp;quot; &lt;br /&gt;
&lt;br /&gt;
De plus j'ai été amené à empiriquement mettre des temporisations, pour laisser le temps au temps... C'est notamment le cas pour la modification de la courbe par l’utilisateur (amplitude, nombre de points d'inflexion).&lt;br /&gt;
&lt;br /&gt;
Bien sûr ces variables  sont invisibles pour l'utilisateur, sinon dans l'historique !&lt;br /&gt;
&lt;br /&gt;
==Quelques particularités du mode local (par rapport à Lab adjustements)==&lt;br /&gt;
&lt;br /&gt;
Voici quelques informations qui peuvent intéresser l'utilisateur. Ces informations sont souvent des particularités du mode local&lt;br /&gt;
&lt;br /&gt;
===Color and Light===&lt;br /&gt;
*Les algorithmes utilisés pour la luminance et le contraste sont différents de ceux utilisés par &amp;quot;Lab adjustements&amp;quot;, ce qui peut amener quelques différences de rendu.&lt;br /&gt;
*L'algorithme de luminance est réalisé de telle manière que en dessous de -90 et jusque -100 pour &amp;quot;lightness&amp;quot;, il est possible d'accroître la &amp;quot;darkness&amp;quot; de l'image, pratiquement jusqu'à obtenir une valeur de luminance proche de 0. Si vous souhaitez accentuer cet effet, réduisez également la chominance et accroissez &amp;quot;scope&amp;quot;.&lt;br /&gt;
*Le mode inverse, peut servir pour l'essentiel, à réaliser des cadres dégradés. Dans ce cas, si vous sélectionnez -100 pour &amp;quot;lightness&amp;quot;, et réduisez la chrominance, la &amp;quot;bordure&amp;quot; sera noire.&lt;br /&gt;
* pour la luminance et le contraste (curseur), vous avez le  choix entre 2 algorithmes : le premier (par défaut) est très proche de ce qui était présent jusque là, le second activé par &amp;quot;Lightness Contrast super&amp;quot; est proche de celui utilisé pour les courbes &amp;quot;super&amp;quot;&lt;br /&gt;
* ne pas hésiter selon le cas, à activer &amp;quot;Global quality&amp;quot; = enhanced  et (défaut) enhanced + chroma denoise&amp;quot;&lt;br /&gt;
====Courbes====&lt;br /&gt;
*Une courbe L=f(L) et une C=f(C) permet de moduler la luminance ou la chrominance pour chaque RT-spot (spot de contrôle) en fonction de la luminance ou de la chrominance. &lt;br /&gt;
*Une courbe L=f(H) permet de moduler la luminance pour chaque RT-spot en fonction de la teinte. &lt;br /&gt;
*Une courbe H=f(H) permet de moduler la teinte pour chaque RT-spot en fonction de la teinte.&lt;br /&gt;
Pour les rendre actives, il est nécessaire d'activer la combobox &amp;quot;Curves type&amp;quot;.&lt;br /&gt;
* deux choix sont offerts : &lt;br /&gt;
** a) Normal : les courbes - notamment la plus complexe à gérer L=f(L) utilise un algorithme proche de celui utilisé avec les curseurs (mode Normal);&lt;br /&gt;
** b) Super : utilise un nouvel algorithme que je pense très performant (le résultat m'a même surpris à la première utilisation).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Attention, lorsque le spot est située dans une zone grise, ou des zones assez uniformes, les artefacts avec le nouvel algorithme (L=F(L) super, et Lightness Contrast super) peuvent être impossible à supprimer, dans ce cas privilégier l’algorithme &amp;quot;normal&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Exposure===&lt;br /&gt;
Ce module &amp;quot;ressemble&amp;quot; à celui en mode global RGB, mais :&lt;br /&gt;
* il fonctionne entièrement en mode L*a*b*, d'où des différences de rendu;&lt;br /&gt;
* il n'a pas les curseurs &amp;quot;lightness, chroma et contraste&amp;quot; dont les fonctions sont déjà présentes dans &amp;quot;Color and Light&amp;quot;&lt;br /&gt;
* il y a une seule courbe &amp;quot;contraste&amp;quot;, similaire à celle de L=F(L) présente dans &amp;quot;Color and Light&amp;quot;. Il est évident que le rendu de cette courbe est différent de &amp;quot;Tonecurve&amp;quot; qui agit en mode RGB. Vous pouvez si vous le souhaitez activer les 2 courbes L=f(L) dans &amp;quot;Color and Light&amp;quot; et &amp;quot;Exposure&amp;quot; &lt;br /&gt;
&lt;br /&gt;
===Vibrance===&lt;br /&gt;
Module similaire à celui du menu principal.&lt;br /&gt;
&lt;br /&gt;
===Blur and Noise===&lt;br /&gt;
Blur n'est actif que si Radius supérieur ou égal à 2.&lt;br /&gt;
&lt;br /&gt;
En réduisant notablement la valeur par défaut de &amp;quot;scope&amp;quot; et en agissant éventuellement sur &amp;quot;Luminance only&amp;quot; il est possible d'obtenir des flous différenciés selon la teinte.&lt;br /&gt;
&lt;br /&gt;
Vous disposez (octobre 2017), de 3 méthodes :&lt;br /&gt;
* &amp;quot;normal&amp;quot; : l'algorithme de détection de forme a été amélioré. Il se rapproche de celui utilisé dans les autres modules.&lt;br /&gt;
* &amp;quot;inverse&amp;quot; : algorithme simplifié, ne faisant pas intervenir &amp;quot;scope&amp;quot;. L'inversion est grossière et ne permet pas une séparation fine des zones à traiter / conserver.&lt;br /&gt;
* &amp;quot;symmetric&amp;quot; : ce nouvel algorithme utilise les mêmes processus que &amp;quot;normal&amp;quot; et par l'utilisation de &amp;quot;scope&amp;quot; l'utilisateur peut cibler plus précisément l'action. &lt;br /&gt;
&lt;br /&gt;
Attention:&lt;br /&gt;
* travailler en mode inverse, va flouter des zones importantes qui ne pourront pas être corrigées ensuite&lt;br /&gt;
* l'action de &amp;quot;scope&amp;quot; peut être déroutante dans certains cas : par exemple pour un portrait les yeux - différents de la peau - seront floutés si &amp;quot;scope&amp;quot; est trop faible.&lt;br /&gt;
&lt;br /&gt;
===Tone mapping===&lt;br /&gt;
Attention aux artefacts lorsque les aplats (ciels, zones grises...) sont d'une teinte similaire au spot de contrôle. Dans le cas d'artefacts, mettre le curseur &amp;quot;iterations&amp;quot; de &amp;quot;Reduce artefacts - improve algorithm&amp;quot; à zéro.&lt;br /&gt;
&lt;br /&gt;
===Retinex===&lt;br /&gt;
Le nombre de réglages est réduit, par rapport au mode standard. D'autre part, &amp;quot;Retinex local&amp;quot; agit en fin de processus contrairement au mode standard qui est au début du processus Raw.&lt;br /&gt;
Depuis la version mip 10002, la courbe &amp;quot;transmission gain&amp;quot; est spécifique à chaque RT-spot.&lt;br /&gt;
&lt;br /&gt;
===Sharpening===&lt;br /&gt;
Seul le mode &amp;quot;RL deconvolution&amp;quot; est proposé.&lt;br /&gt;
&lt;br /&gt;
===Contrast By Detail Levels===&lt;br /&gt;
* 5 niveaux au lieu de 6 pour le mode pleine image.&lt;br /&gt;
* pas de curseurs pour la gestion de la peau; le système utilisé par les RT-spot le remplace.&lt;br /&gt;
* ajout d'un curseur pour la chroma&lt;br /&gt;
* Attention aux artefacts lorsque les aplats (ciels, zones grises...) sont d'une teinte similaire au RT-spot. Dans le cas d'artefacts, mettre le curseur &amp;quot;iterations&amp;quot; de &amp;quot;Reduce artefacts - improve algorithm&amp;quot; à zéro.&lt;br /&gt;
&lt;br /&gt;
===Denoise===&lt;br /&gt;
* par rapport au mode pleine image, seul l'outil wavelet est utilisé: donc pas de fonction de Fourier, ni de medians&lt;br /&gt;
* moins de curseurs et de courbes&lt;br /&gt;
* par contre, vous pouvez différencier l'action sur la luminance et la chrominance en fonction de la grosseur du bruit - fine ou coarse.&lt;br /&gt;
&lt;br /&gt;
==Réduction des défauts: capteur sale - yeux rouges - ...==&lt;br /&gt;
Par conception &amp;quot;Locallab&amp;quot; n'a pas été conçu pour éliminer ces défauts. Néanmoins par effet de bord, certains défauts apparents et gênant en photographie peuvent être réduits voire supprimés. Ceci bien sûr n'est pas incompatible avec d'autres modules plus spécialisés incorporés ou non à &amp;quot;Locallab&amp;quot;...&lt;br /&gt;
Au moins 3 fonctions présentes, en adaptant l'usage, peuvent être utilisées, séparément ou ensemble :&lt;br /&gt;
* &amp;quot;Color and light&amp;quot; pour des défauts ponctuels ;&lt;br /&gt;
* &amp;quot;Contrast by detail level&amp;quot; pour des défauts répartis ;&lt;br /&gt;
* &amp;quot;Blur and Noise&amp;quot; en complément éventuel : attention cette action est assez destructrice - à utiliser avec modération.&lt;br /&gt;
&lt;br /&gt;
Vous pouvez agir soit:&lt;br /&gt;
* directement, cas général, sur le fichier &amp;quot;raw&amp;quot;, ou &amp;quot;TIF&amp;quot;, etc.&lt;br /&gt;
* soit sur le fichier flat-field si vous en avez élaboré un.&lt;br /&gt;
  &lt;br /&gt;
===Utilisation avec le module &amp;quot;Color and Light&amp;quot;===&lt;br /&gt;
* Activez &amp;quot;Color and Light&amp;quot;&lt;br /&gt;
*Vous pouvez utiliser l'équivalent d'une fonction &amp;quot;yeux rouges&amp;quot; en choisissant un encadrement assez serré de l’œil - sélecteur circulaire centré sur le rouge, délimiteurs de spot proches de l’œil - une valeur de scope réduite, puis agir sur réduction &amp;quot;lightness&amp;quot; -100, et réduction chrominance -100.&lt;br /&gt;
*De la même manière vous pouvez réduire les défaut du capteur de type &amp;quot;Spot IR&amp;quot;,  en choisissant un encadrement assez serré du défaut - sélecteur circulaire centré sur le défaut, délimiteurs de spot proches du défaut - puis agir sur &amp;quot;chrominance&amp;quot; en réduisant la valeur, agir éventuellement sur &amp;quot;scope&amp;quot; pour réduire l'étendue de l'action.&lt;br /&gt;
*Vous pouvez dans des cas simples, réduire les défauts de type &amp;quot;capteur encrassé&amp;quot; notamment lorsque celui-ci est gras. Ceci se traduit par des taches qui apparaissent sur les fonds unis. Pour cela choisissez un encadrement assez serré du défaut - sélecteur circulaire centré sur le défaut (adaptez la taille du spot) , délimiteurs de spot pas trop proches du défaut pour permettre une transition peu visible. Puis: a) réduisez &amp;quot;Transition&amp;quot; à des valeurs faibles; b) cochez &amp;quot;Lightness contrast super&amp;quot;; c) agissez sur &amp;quot;luminance&amp;quot; et éventuellement sur &amp;quot;chrominance&amp;quot; pour approcher le rendu de la zone polluée à celui de la zone saine; d) agir modérément sur &amp;quot;scope&amp;quot; pour moduler l'action souhaitée.&lt;br /&gt;
&lt;br /&gt;
===Utilisation avec le module &amp;quot;Contrast by detail levels&amp;quot;===&lt;br /&gt;
Dans le cas de capteur encrassé (de type &amp;quot;graisse&amp;quot;), et lorsque la zone est importante ou pour une série de petits défauts, Il peut être utile d'utiliser &amp;quot;Contrast by details levels&amp;quot; qui va agir comme un outil &amp;quot;wavelet&amp;quot; sur la luminance et aussi si nécessaire sur la chrominance. Dans ce cas: a) mettez le Spot de sélection sur un défaut prononcé (en adaptant sa taille si nécessaire); b) choisissez une zone de sélection large pour couvrir la majorité de la surface concernée par les défauts; c)Sélectionnez une valeur de transition assez importante; d) Activez &amp;quot;Contrast by detail levels&amp;quot; et agissez sur les niveaux 3 et 4 ou plus faibles en réduisant le contraste (valeurs inférieures à 100) et en agissant si nécessaire sur le curseur chroma.&lt;br /&gt;
&lt;br /&gt;
== Temps de traitement et utilisation de la mémoire ==&lt;br /&gt;
&lt;br /&gt;
Lorsqu'on utilise la sortie JPG ou TIF, et pour le mode &amp;quot;normal&amp;quot;, l'algorithme n'effectue les calculs que pour la zone délimitée. En ce sens les temps de traitement et l'occupation mémoire sont réduits.&lt;br /&gt;
Bien sûr le temps de traitement va dépendre du nombre de spots de contrôles, de leur taille, et du type de traitement.&lt;br /&gt;
&lt;br /&gt;
Si on exclue &amp;quot;Denoise&amp;quot; et &amp;quot;Sharp&amp;quot;, les temps de traitement sont de l'ordre de quelques dixièmes de seconde par spot de contrôle, et le besoin en mémoire de l'ordre de quelques centaines de M.&lt;br /&gt;
&lt;br /&gt;
Deux réglages agissent fortement sur les temps de traitement et le besoin en mémoire :&lt;br /&gt;
* denoise qui ajoute selon la taille du spot de contrôle de l'ordre de 1 seconde et 1 M de mémoire.&lt;br /&gt;
* quality enhanced and chroma denoise, qui ajoute environ selon le spot de contrôle de l'ordre de 0.5 secondes et 0.6 M.&lt;br /&gt;
&lt;br /&gt;
==Onglet Preferences==&lt;br /&gt;
J'ai regroupé ici, les réglages (repris par ailleurs sur cette page) accessibles depuis &amp;quot;Preferences&amp;quot;&lt;br /&gt;
* si vous sélectionnez en &amp;quot;Preferences&amp;quot; / &amp;quot;General&amp;quot; / &amp;quot;Local adjustements&amp;quot;, en cochant la case &amp;quot;Show spot delimiters&amp;quot;, vous obtiendrez une approximation de la zone concernée par le spot et ses réglages&lt;br /&gt;
* Vous pouvez choisir la valeur par défaut de &amp;quot;Global Quality&amp;quot;, par exemple si vos images sont très peu bruitées, et ainsi réduire notablement les temps de traitement.Pour cela, aller dans &amp;quot;Preferences&amp;quot;, &amp;quot;Performance and Quality&amp;quot;, &amp;quot;Local adjustements&amp;quot; et choisir entre Les 3 propositions. C'est ce choix qui sera proposé par défaut à l'utilisateur pour chaque nouveau &amp;quot;Spot&amp;quot;, bien sûr il est possible ensuite de modifier ce choix, en sélectionnant la combo-box &amp;quot;Global Quality&amp;quot;&lt;br /&gt;
* Fichiers &amp;quot;mip&amp;quot;: &lt;br /&gt;
**le choix de l'emplacement est possible à partir de : Preferences / Image processing / Mip Profiles&lt;br /&gt;
** effacement : aller dans &amp;quot;Preferences&amp;quot; / &amp;quot;Files browser&amp;quot;, puis &amp;quot;Clear mip&amp;quot; et / ou &amp;quot;clear pp3&amp;quot; - si bien sûr vous avez positionné &amp;quot;mip&amp;quot; et &amp;quot;pp3&amp;quot; dans le cache, sinon il faudra exécuter cette opération manuellement dans le dossier courant. La présence d'anciennes versions de fichiers &amp;quot;mip&amp;quot; ou de &amp;quot;pp3&amp;quot; peut amener de l'instabilité voire un crash du système.&lt;br /&gt;
&lt;br /&gt;
==Évolutions==&lt;br /&gt;
En dehors des habituelles mises aux points, bug, améliorations, réglages, interface, etc. Il serait souhaitable :&lt;br /&gt;
* d'améliorer le GUI, pour pouvoir créer / sélectionner / modifier chaque point de contrôle.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
En termes &amp;quot;informatique&amp;quot;, il devrait être possible pour accroître la lisibilité et la maintenance, d'intégrer l'ensemble du code fichiers *.mip qui actuellement sont linéairement intégrés à Improccoordinator.cc, dcrop.cc et simpleprocess.cc à des procédures &amp;quot;void&amp;quot;, à l'exemple de rgbproc.cc&lt;/div&gt;</summary>
		<author><name>Sguyader</name></author>
	</entry>
	<entry>
		<id>http://rawpedia.rawtherapee.com/index.php?title=Local_Lab_Controls&amp;diff=3295</id>
		<title>Local Lab Controls</title>
		<link rel="alternate" type="text/html" href="http://rawpedia.rawtherapee.com/index.php?title=Local_Lab_Controls&amp;diff=3295"/>
		<updated>2017-10-26T17:09:49Z</updated>

		<summary type="html">&lt;p&gt;Sguyader: Created page with &amp;quot;==What kind of local control?==  Several types of local control exist in mainstream applications : # “lasso”, associated with layers and fusion masks (e.g. Photoshop©)....&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What kind of local control?==&lt;br /&gt;
&lt;br /&gt;
Several types of local control exist in mainstream applications :&lt;br /&gt;
# “lasso”, associated with layers and fusion masks (e.g. Photoshop©). This kind of control is widespread (Photoshop, Gimp, Darktable…) and users tend to favor those, at the expense of the type desciribed in 3. below, which is less well known;&lt;br /&gt;
# dedicated tools for the removal of image defects such as « red eyes », or « spots » associated with sensor imperfections or dirt;&lt;br /&gt;
# “U-points” controls, used until recently in Nikon Capture NX2©, or as an add-on to other software such as Nik Software©. For those (rare now) who tried such programs, there’s no way turning back to layers and fusion masks! This type of local control requires learning something different, and a cognitive “unprogramming”. In my opinion, this kind of local control is globally more efficient.&lt;br /&gt;
&lt;br /&gt;
The algorithm developed in the current version of RawTherapee is close in its principle to the U-points described above. Of course, the code used in Nik Software is not disclosed, but several years ago I was attracted by the simplicity of use and the efficiency of U-points, and I started developing a product which would use neither lassos, nor layers or fusion masks. Of course, nothing prevents us from having all 3 types of local control in the same program.&lt;br /&gt;
&lt;br /&gt;
The current version of the filter is perfectible, particularly regarding the user interface (GUI):&lt;br /&gt;
* for managing and viewing the RT-spots (control spots) on screen,&lt;br /&gt;
* for manipulating the different sliders, which would ideally be better if integrated to the actual control points, as done in Nik Software.&lt;br /&gt;
&lt;br /&gt;
However, those two aspects don’t harm everyday use, nor code portability.&lt;br /&gt;
&lt;br /&gt;
In order to improve manipulation and avoid long menus on screen, I added a GUI interface which is similar to the one used in the Wavelet tab, with “expanders”. Thus for each module (“Color and Light”, “Blur”, “Retinex”, …) you can choose to:&lt;br /&gt;
# display (or not) the full list of commands: sliders methods, curves…&lt;br /&gt;
# activate (or not) the all the functions of the module.&lt;br /&gt;
&lt;br /&gt;
Warning: choice 2. activates or cancels all the RT-spots; it would be possible in theory to add this capability to every single RT-spot, but for what purpose?&lt;br /&gt;
&lt;br /&gt;
===Lab and RGB local controls===&lt;br /&gt;
* The first algorithms are coded in L*a*b* mode with the following modules: “Color and Light”, “Blur / Add noise”, “Retinex”, “Tone mapping”, “Sharpen”, “Contrast by Detail Levels”, “Denoise”. Two additional modules have been added: “Exposure” and “Vibrance”.&lt;br /&gt;
* See below for the principles of the different algorithms, but one key point to remember for shape detection and artifacts avoidance, is that the Lab mode preserves the “hue” tint, which is crucial.&lt;br /&gt;
* The idea of an “RGB” module comes to one’s mind, with a minima:&lt;br /&gt;
** a “White balance” module, which would allow to locally adjust the white balance, for example to warm up shadows, or to deal with mixed scene lighting such as “daylight” and “tungsten”. This module needs to be inserted just after “demosaic”.&lt;br /&gt;
&lt;br /&gt;
====Auto White balance====&lt;br /&gt;
The “White balance” module (in the “autowblocal” branch) serves two purposes:&lt;br /&gt;
* allowing a local adjustment of the white balance (of course)&lt;br /&gt;
* testing new algorithms for automatic white balance adjustment:&lt;br /&gt;
** in general use (full image), in order to achieve better results than with the current algorithm. Of course one will tell me that I should create a specific branch for “White balance”, but here I’m trying to hit two targets with one bullet.&lt;br /&gt;
&lt;br /&gt;
As a reminder, I’ve been asked in 2012 and 2013 to develop an iterative white balance “Auto Robust WB[http://ieeexplore.ieee.org/document/1649677/]”. At that time, another developer and I had spent a lot of time on this for an unsatisfactory result, so we gave up. Since then, benefiting from this experience, I resumed this work but in the reverse way! Now, if I’m correct, the algorithm works. I took advantage of this new capability (currently working on raw images only) to search in the academic literature for other auto WB algorithms. I found, and developed two new algorithms:&lt;br /&gt;
* “auto edge”[https://www.researchgate.net/publication/301419990_A_Method_to_Improve_Robustness_of_the_Gray_World_Algorithm]: the idea is to create an accentuation mask allowing to reinforce parts of the image where details are more prevalent, compared to flatter regions.&lt;br /&gt;
* “auto standard deviation”[http://www.acad.bg/rismim/itc/sub/archiv/Paper3_1_2012.pdf]: here, the image (or part of it for the local control) is divided in 12 zones, for each of which mean and standard deviation are computed, and the result assembled.&lt;br /&gt;
A third algorithm, “Color by correlation”[https://courses.cs.washington.edu/courses/cse467/08au/labs/l5/whiteBalance.pdf], looks promising but I’m facing several difficulties. After many trials of many types, the results are just too erratic…&lt;br /&gt;
&lt;br /&gt;
I also added the notion of gamma:&lt;br /&gt;
* the same principles which deal with luminance distribution – gamma sRGB – used in the main RawTherapee code.&lt;br /&gt;
&lt;br /&gt;
As a reminder, the automatic white balancing is a totally non deterministic mathematical problem. The algorithms may perform more or less well (and faster or slower), but a perfect result can’t exist! Why is it so? If one is referring to the principles of color management ([http://rawpedia.rawtherapee.com/Color_Management_addon/fr#Balance_des_blancs]), it is necessary to have knowledge of the three of: the colored object, the illuminant and the observer. At least two of those are unknown in practice. In addition, the environment in which an image is shot is not known while it has an effect on the perception (CIECAM), and the same is true during both image editing and viewing. The mission is thus almost impossible!&lt;br /&gt;
&lt;br /&gt;
The aim of the “White balance” module is '''for testing the algorithms''', there are 7 of them at least, and twice that number if “gamma sRGB” is considered. Indeed, in order to circumvent the obstacles encountered five years ago, instead of the using the image before demosaicing, I used the image just after demosaicing, allowing to apply (or not) “gamma sRGB”, ending in the same conditions as in normal use (but without normal “White balance” and “ICC or DCP” profile).&lt;br /&gt;
&lt;br /&gt;
Ideally, we should test the algorithms on many images, as well: which algorithm(s) to keep and implement in normal – global RGB – mode (maybe one or two, in addition to the current algorithm which we should keep for compatibility).&lt;br /&gt;
&lt;br /&gt;
====Local control of White balance====&lt;br /&gt;
The local control is currently limited to 1 spot only, but there’s no difficulty to increase this if users want so… while waiting for the evolution of “locallab”.&lt;br /&gt;
&lt;br /&gt;
Of course, I hear voices say “it doesn’t work”, or “the output doesn’t match with the preview”. But it does work! And it is more than evident that matching exactly the preview is by definition almost impossible… (differences between shadows, sun light, different illuminants, etc…) whatever the relevance of the algorithm.&lt;br /&gt;
&lt;br /&gt;
==What are the challenges to be solved?==&lt;br /&gt;
Several general issues need to be solved so as to achieve smoothness in use:&lt;br /&gt;
* allow an (almost) unlimited number of RT-spots (the name we chose for the control spots in RawTherapee);&lt;br /&gt;
* adapt the local algorithms to be aware of scale, because many of them take the image size – the treated area – into account. This aspect is fundamental, particularly with curves which act on the whole image;&lt;br /&gt;
* minimize memory use and computation time for JPG and TIFF output;&lt;br /&gt;
* allow easy updates in case of evolution of either the algorithms or the number of methods/modules;&lt;br /&gt;
* optimize (minimize) the differences between the preview and the output.&lt;br /&gt;
* etc…&lt;br /&gt;
&lt;br /&gt;
For each RT-spot:&lt;br /&gt;
* allow for the action to occur, on user choice, either inside or outside (“Inverse” mode) of the selection area;&lt;br /&gt;
* allow shape detection, on user choice, in order to limit the action based on features/shapes;&lt;br /&gt;
* take care of the transition between the center of the treated area and the other parts of the image;&lt;br /&gt;
* etc…&lt;br /&gt;
&lt;br /&gt;
Currently, RT-spots are operational in Lab mode with the following modules and methods:&lt;br /&gt;
# “Color and Light”: “Lightness”, “Chrominance”, “Contrast” in normal mode with 4 curves L=f(L), L=f(H), C=f(C), H=f(H), and in “inverse” mode;&lt;br /&gt;
# “Exposure”: normal mode only;&lt;br /&gt;
# “Vibrance:” normal mode only;&lt;br /&gt;
# “Blur &amp;amp; noise”: normal and “inverse” modes;&lt;br /&gt;
# “Retinex”: normal and “inverse” modes, now also with “transmission gain” curve;&lt;br /&gt;
# “Sharpening”: normal and “inverse” modes;&lt;br /&gt;
# “Contrast by detail levels” (CBDL): normal mode only;&lt;br /&gt;
# “Denoise”: normal mode only.&lt;br /&gt;
&lt;br /&gt;
==General principles==&lt;br /&gt;
===The RT-spot object===&lt;br /&gt;
As I mentioned earlier, the system used in RT is similar to the one developed in Nik Software, but with some significant differences:&lt;br /&gt;
* each RT-spot can be viewed as an object with a number of fields (about 70 as of today), made of sliders, curves, control points, etc…;&lt;br /&gt;
* each field, grouped in modules, can be activated or not, and have different parameter values according to their nature;&lt;br /&gt;
* the modules are made to be coherent for the user: “Color and Light”, “Exposure”, “Contrast”, “Vibrance”, “Blur”, “Retinex”, “Sharpening”, “Tone Mapping”, “Contrast by detail levels”, “Denoise” ;&lt;br /&gt;
* the number of RT-spot objects can vary from 2 up to 500 ;&lt;br /&gt;
* data describing the RT-spot objects are stored in text files with .mip extension ;&lt;br /&gt;
* creating, modifying and tracking of the RT-spot objects are done in a “for” loop;&lt;br /&gt;
* there’s no code duplication.&lt;br /&gt;
&lt;br /&gt;
===Partitioning into 4 zones – previewing the RT-spot area===&lt;br /&gt;
When the user selects an RT-spot, the screen preview shows:&lt;br /&gt;
* a center, made of a circle whose diameter and position can be adjusted directly using the mouse or the sliders;&lt;br /&gt;
* two horizontal and two vertical handles, whose position can be modified directly using the mouse or the provided sliders, controlling the extent of the area affected by the RT-spot;&lt;br /&gt;
* if &amp;quot;Show spot delimiters&amp;quot; is checked in &amp;quot;Preferences&amp;quot; &amp;gt; &amp;quot;General&amp;quot; tab &amp;gt; &amp;quot;Local adjustments&amp;quot;, one can visualize approximately the area affected by the spot. Because I couldn’t work cleanly with the « arc/ellipse/scale » function in the Cairo graphics library, I made each quadrant defined by a pseudo-ellipse made of 3 Bézier curves joining each other. In most cases the approximation is satisfying… To help grabing the 4 handles, I made them longer (the Bézier curves are inactive!).&lt;br /&gt;
&lt;br /&gt;
We obtain 4 zones, whose orientation can be modified (the default rotation angle is set to zero). Those 4 zones have each of their vertices connected by imaginary ellipses.&lt;br /&gt;
&lt;br /&gt;
It is possible to drag the handles outside the image preview area.&lt;br /&gt;
&lt;br /&gt;
It should be possible to replace the ellipse with a hand drawn curve (even if I think its usefulness is debatable because of the existence of the shape detection algorithm), as long as the homothetic transform of the curve doesn’t intersect with the original curve. Although the benefits from this intellectually satisfying “improvement” should negligible in the case of the RT-spots, it will be possible to make the current RT-spots and lasso type of controls coexist eventually.&lt;br /&gt;
&lt;br /&gt;
===Tint, chroma, luminance references and the algorithm principle in “normal” mode===&lt;br /&gt;
In order to develop an efficient shape detection algorithm:&lt;br /&gt;
* The central circle zone is used as the reference. Based on the diameter value chosen by the user, the algorithm computes the tint (hue), chroma and luminance averages.&lt;br /&gt;
* The choice of the central zone diameter depends on the use intent. For example, if working on a foliage area the user would benefit from choosing a smaller diameter value in order to select only the foliage green; in contrast, for skin tones the user should increase the diameter to avoid the detection of parasites (noise, eye lashes…).&lt;br /&gt;
* For each quadrant, depending on the the value of the “Scope” slider, the algorithm does:&lt;br /&gt;
# take into account the tint difference between the zone center and the affected pixel;&lt;br /&gt;
# through a complex algorithm based on the deltaE notion (perceived difference between two colors, taking tint, chroma and luminance into account), decrease the amount of applied effect as a function of the difference between the central zone and the affected pixel;&lt;br /&gt;
# follow either a linear or a parabolic law to adjust the amount of applied effect, based on the specific the case.&lt;br /&gt;
&lt;br /&gt;
This allows adapting the amount of effect according to the above-mentioned criteria. For example, if the central circle is located on foliage, the action will be limited to the leaves, without touching the background (which would be impossible to obtain with the lasso type of controls). Additionally, if some other foliage resides within the area covered by the RT-spot, it will also be affected.&lt;br /&gt;
* Adjusting the value of the “Transition” slider modifies the transition of the effect (from the center to the edge): on 50, the inner (linear) half will get the full 100% action/effect, while the effect in the outer half will gradually transition from 100% to 0% towards the edge;&lt;br /&gt;
* By increasing the value of “Scope”, progressively more of the selected area is taken into account, whatever the tint, chroma and luminance;&lt;br /&gt;
* Conversely, by decreasing the “Scope” value the effect will get limited to the pixels which are more similar (in terms of deltaE) to the reference zone.&lt;br /&gt;
&lt;br /&gt;
The shape detection algorithm works in “Normal” mode except for some modules (“Denoise”). It’s not implemented in “Inverse” mode, doing so would not make sense.&lt;br /&gt;
&lt;br /&gt;
The algorithm will see its performance increase when the user chooses “Enhanced” or “Enhanced + chroma denoise” in the “Global quality:” combobox. The second choice additionally applies a low amount of chroma noise reduction in order to get rid of artifacts which could be brought up by the “Enhanced” algorithm (note that the chroma denoise step increases memory use and computing time).&lt;br /&gt;
&lt;br /&gt;
The algorithm is used in full capacity for “scope” &amp;lt; 20.&lt;br /&gt;
&lt;br /&gt;
===Why no alternative algorithms?===&lt;br /&gt;
It should be possible to implement other shape detection algorithms than the deltaE-based one used currently, for example:&lt;br /&gt;
* edge detection algorithms such as “Canny” or “Sobel”;&lt;br /&gt;
* wavelet decomposition.&lt;br /&gt;
&lt;br /&gt;
But in both cases, everything would have to be done!&lt;br /&gt;
&lt;br /&gt;
===Functioning in “inverse” mode===&lt;br /&gt;
When it is available, the “Inverse” mode is extremely simplified: only the “Transition” slider can be used to apply the effect.&lt;br /&gt;
As of late October 2017, I devised a new method for “Inverse” mode. It is limited to the “Blur &amp;amp; Noise” module (see the corresponding section below).&lt;br /&gt;
&lt;br /&gt;
===Maximum number of RT-spots===&lt;br /&gt;
By default the number of available RT-spots is 8. You can choose any number between 2 and 499. For this you only need to change the parameter “Nspot” in the “options” file (for example: Nspot=12). Restart RawTherapee for the modification to be taken into account.&lt;br /&gt;
&lt;br /&gt;
===The “super” algorithm===&lt;br /&gt;
The key to “success” was the algorithm implemented in late January 2017, which works this way:&lt;br /&gt;
# on the pixel data which are within the area covered by the RT-spot, the algorithm applies either a “traditional” curve, a slider, or a normal transfer function (“Retinex”, “Tone Mapping”, “Contrast by detail levels”, “Vibrance”, …);&lt;br /&gt;
# the LUT or the transfer function is converted into an equivalent of a slider, separating negative and positive values so that the function can be viewed as multiple sliders (as many sliders as there are pixels) in the -100, 0, +100 interval;&lt;br /&gt;
# the data are passed to the shape detection function – the 4 quadrants. For every pixel, the difference in terms of tint, chroma and luma is computed with regards to the central reference. The linear variation equations are estimated for luminance (L=f(L)), chroma (C=f(C)) or transfer functions;&lt;br /&gt;
# different corrections are applied to account for the environment (sky, skin tones…)&lt;br /&gt;
# a correction is made (with threshold and iterations) in order to avoid correcting (or only slightly, based on the user’s choice) the gray or neutral tones which are in the same tint as the reference (but with a low chroma value);&lt;br /&gt;
# the parameters are weighted based on the shape of the RT-spot (ellipses) and the transition zone;&lt;br /&gt;
# the values of the “Global quality:” parameters are important, particularly so for images with a low amount of noise – chroma noise is interpreted by the algorithm being of the same color as the spot. It is thus necessary to suppress this noise, that is the purpose of “Enhanced + chroma denoise” (this algorithm may not be sufficient, though – in this case using the local “Denoise” module may be useful).&lt;br /&gt;
&lt;br /&gt;
This new (“super”) algorithm seems to perform generally well, but in the event when the RT-spot is located in a gray/neutral or flat area, the algorithm may fail. In such cases, using the old algorithm is recommended (except for “Retinex”, “Tone Mapping” and “Contrast by detail levels” for which it is made unavailable for the sake of code simplicity).&lt;br /&gt;
&lt;br /&gt;
===Artifact reduction and the “Global quality” algorithms===&lt;br /&gt;
By default, “Global quality:” is set to “Enhanced + chroma denoise”. Whereas it increases computation time, it is still generally preferable. In case one wants a more responsive preview, “Enhance” or “Standard” can be chosen (good for exploring the image).&lt;br /&gt;
* two sliders allow reducing artifacts and improving the algorithm’s rendering. They work based on chroma, in neutral/gray tones. To completely remove its effect, one can simply set “iterations=0”. These sliders may be used for &amp;quot;Color light&amp;quot;, &amp;quot;Exposure&amp;quot;, &amp;quot;Retinex&amp;quot;, &amp;quot;Vibrance&amp;quot;, &amp;quot;Tone mapping&amp;quot; and &amp;quot;Contrast by detail levels&amp;quot;;&lt;br /&gt;
* for (even slightly) noisy images, the algorithms may be misled. In this case it is recommended to keep &amp;quot;Global quality:”  set to “Enhanced + chroma denoise&amp;quot;, and (sometimes) activate the local “Denoise” module and adjust the sliders very gently (including “Luminance”);&lt;br /&gt;
* under some circumstances, with “Tone Mapping” for example, the artifact reduction algorithm may actually generate more artifacts. When it happens, set “iterations=0”.&lt;br /&gt;
&lt;br /&gt;
If your images are generally clean (no or very low noise), you can choose to have “Standard” as the default for “Global quality:” – this will speed up the image processing. To do so, go to “Preferences” &amp;gt; “Performance and quality” tab &amp;gt; “Local adjustments” and choose the “Standard” algorithm among the 3 options. This will become the new default  when new RT-spots are created, but of course the algorithm can still be changed on the fly by choosing from the “Global quality” combo box.&lt;br /&gt;
&lt;br /&gt;
===Avoid color shift===&lt;br /&gt;
The “Avoid color shift” checkbox serves two purposes:&lt;br /&gt;
* put the colors within the current working profile gamut, using a relative colorimetry;&lt;br /&gt;
* adjust colors using a “Munsell” correction – particularly for red-orange and blue-purple colors, when saturation in the L*a*b* space has changed significantly.&lt;br /&gt;
&lt;br /&gt;
===“mip” files – Principles of the multi-point algorithm===&lt;br /&gt;
For the local control system to work and keep track of RT-spot objects, a text file – similar to a pp3 – is written in 2 possible places:&lt;br /&gt;
* next to the edited image file. If, for example, you edit an image named ASC4509.NEF, a new file named ASC4509.NEF.mip will be generated in the same folder. In this case, several sessions can be open for the same image, as long as copies of the image are stored in different folders. However, the folder names in the path have to contain ASCII characters only, otherwise it will make the program crash;&lt;br /&gt;
* in the dedicated “mip” folder, within the “cache” directory (through an MD5 hash number which identifies the file). This is the default. If chosen, when multiple copies of the same file exist in distinct folders, editing them creates as many “mip” files. This option allows the use of non ASCII characters in the folder names and path.&lt;br /&gt;
&lt;br /&gt;
The choice between these two behaviors is made in “Preferences” &amp;gt; “Image processing” tab &amp;gt; “Mip profiles”.&lt;br /&gt;
&lt;br /&gt;
The “mip” files contain the data which are passed to RawTherapee through processes of the “procparams” type, and LUTs which allow editing in zoom mode. When updating RawTherapee to a new version, it may be required to delete the “mip” files (or the whole cache) to avoid a potential crash of the application. This can be achieved by going to “Preferences” &amp;gt; “File browser” tab, then choosing “Clear mip” and/or “Clear pp3” – all this is valid only if “mip” and “pp3” files have been set to be saved to the cache folder, otherwise they will have to be manually deleted from the working folder. Keeping older “mip” and “pp3” files may lead to instability or crashes of the application.&lt;br /&gt;
&lt;br /&gt;
====Architecture of the filter====&lt;br /&gt;
When I “ventured” into a multi-point, no-layer and no-mask system, code duplication had to be avoided. Indeed, it is unthinkable to consider, for 10 RT-spots, generating 10 GUI code blocks, and just as many code blocks in “rtengine”. After careful consideration, the idea was to have a file updating and tracking in real time – i.e. a file which would follow each modification made by the user – the actions/modifications history.&lt;br /&gt;
&lt;br /&gt;
Of course, the parameters used by RawTherapee for the GUI and for the main code through “params” are of different types:&lt;br /&gt;
* numeric: integer, float, double,…&lt;br /&gt;
* boolean&lt;br /&gt;
* string (in choice menus for the different modules)&lt;br /&gt;
* curves, through “vectors” of type double with dynamic dimension&lt;br /&gt;
* …&lt;br /&gt;
&lt;br /&gt;
====Data conversion====&lt;br /&gt;
In order to simplify data management, the first step is to convert all data to integers. Sometimes this can lead to a slight precision loss, which I think is negligible.&lt;br /&gt;
* This operation is very simple for numeric values, even though in some cases (such as hue, which is expressed in radians in the interval [-Pi, +Pi]) it needs a double “float*100 and /100 conversion to keep precision.&lt;br /&gt;
* It is logical for boolean operations and methods.&lt;br /&gt;
* However, it is a complex matter regarding curves. The values to be recorded in the “mip” file are of type vector&amp;lt;double&amp;gt;, in a dynamic table of numeric values. There may be a simpler way, by using existing functions from “procparams”, but I didn’t suceed. &lt;br /&gt;
Nevertheless, I could get around this by:&lt;br /&gt;
# converting doubles to integers with 3 significant figures – which is largely enough,&lt;br /&gt;
# then converting the “vector” to a variable length character string,&lt;br /&gt;
# the writing and reading of this character string and converting to a vector dynamically using an appropriate function (”strcurv_data”). Note that this function allows adjusting the curves within the limit of 16 inflection points (Bézier curve) for the flat curve, and 32 points for the diagonal, which should be enough. Whether this would not be enough, it should be possible to increase that number, though compatibility would be compromised.&lt;br /&gt;
&lt;br /&gt;
====Some elements about curves====&lt;br /&gt;
The implementation of curves has been a complex task, particularly since:&lt;br /&gt;
# each curve needs its own reset function – resize() at each iteration,&lt;br /&gt;
# which implies oddities regarding their description, for example the diagonal curve gets initialized with several points, despite it looks being “empty”. This is mandatory for correct functioning, but this means that the curve is always open/active. Consequently, to avoid some unwanted loss of computation time in “preview” mode, the user has to activate the curve by clicking on the “curves” combobox. The same activation is necessary for L=f(H) and C=f(C) curves. While clicking enabling the “curves” (linear) would seem to be a better solution, it didn’t work despite many trials.&lt;br /&gt;
# during all the procedure, we need to set each &amp;quot;params&amp;quot; value to &amp;quot;clear&amp;quot; for curves, for each LUT, at each iteration and then through a &amp;quot;vector&amp;quot; to reassign the good, updated values to &amp;quot;curve params&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
====Data storing and dynamic use====&lt;br /&gt;
Once data have been converted:&lt;br /&gt;
* they are stored in a text (mip) file,&lt;br /&gt;
* each one is referenced inside a 2-dimension dynamical table:&lt;br /&gt;
# dataspot[x][y] for numeric and boolean values and methods, where “x” is the representative index of the parameter (e.g. “9” is for “lightness”) and “y” represents the current RT-spot (control spot). Value “0” represents the current in-use value (the one stores in “params”).&lt;br /&gt;
# retistr[y], llstr[y], lhstr[y], ccstr[y], hhstr[y], skinstr[y], pthstr[y], exstr[y] for parameters of type “curve”. Currently there are only 8 parameters, used for local “Retinex”, “Color and light” (L=f(L), C=f(C), L=f(H), H=F(H)), “Vibrance” and “Exposure”, but it is easy to add more. “y” is used as above in 1.&lt;br /&gt;
&lt;br /&gt;
The way data are stored and used fits well with improccoordinator.cc (current management / preview) and simpleprocess.cc (TIFF / JPG  output) files, but not so with dcrop.cc and the partial display of the image (RawTherapee’s pipeline).&lt;br /&gt;
&lt;br /&gt;
In this case (zoom / preview) another solution had to be found in order to synchronize the modifications in real time. I made use of LUTs, so that to each entry referenced in the table described above a LUTi(z) is associated, with z=500 possible entries (500 corresponds to the current maximum number of RT-spots, but this limit can be decreased or increased). The LUTi “z” corresponds to the dataspot “y”. A 25,000 entries LUTi (arbitrary number) is used for “retistr”, “llstr”, “lhstr”, “ccstr”, “hhstr”, “skinstr”, “pthstr”, “exstr” for storing each “vector” curve value in memory (up to 69 values stored as integers).&lt;br /&gt;
&lt;br /&gt;
During data processing, exchanges occur between: params, dynamic tables and LUTi. The values used by dcrop.cc are dynamically linked to dynamical tables by parent→.&lt;br /&gt;
&lt;br /&gt;
====Exchange processes and dynamic data storing====&lt;br /&gt;
# reading of the “mip” file to check the version number and guide the updates&lt;br /&gt;
# creating the “mip” file if it doesn’t exist&lt;br /&gt;
# storing the data in LUTi and dynamic tables from the values stored in “params” (index 0 values)&lt;br /&gt;
# first interactive update with the GUI through a transfer function between “rtengine” and locallab.cc (aloListener → localretChanged). This is one of the 3 functions required for the process to work correctly&lt;br /&gt;
# reading of the “mip” file and data storing in dynamic tables (index values ==&amp;gt; y) according to the number of RT-spots&lt;br /&gt;
# creating a loop – according to the number of RT-spots – which updates LUTi (required by “dcrop”) and “params” values from values stored in the dynamic tables&lt;br /&gt;
# call to the “Lab_local” function which contains the algorithms controlling each RT-spot (luminance, sharpness, retinex, denoise, …)&lt;br /&gt;
# second interactive update with the GUI through another transfer function between “rtengine” and “locallab.cc”&lt;br /&gt;
# treatment of the current RT-spot by using the index (0) values from the dynamic tables. These values are attributed to 1) “params”, 2) LUTi and 3) current index values&lt;br /&gt;
# call to the “Lab_local” function for the current RT-spots&lt;br /&gt;
# saving to the “mip” file.&lt;br /&gt;
&lt;br /&gt;
Note that if the user modifies the curve (amplitude, number of inflection points) a third interactive update is made in order to conform all of the data according to events.&lt;br /&gt;
&lt;br /&gt;
====A few unavoidable “fantasies”====&lt;br /&gt;
Of course everything looks simple, the process works if, and only if, all the data are dynamically updated. I’ve tried a lot, went groping, and finally found a working solution… but an uncanny one. There’s probably a more “informatically” correct way to do it, but at this point I’ve done as explained above and hereafter.&lt;br /&gt;
&lt;br /&gt;
The 3 exchanges between “rtengine” and the GUI occur with 3 parameters which actually do nothing in the program except doing the update process:&lt;br /&gt;
# “anbspot” which takes values of 0 or 1&lt;br /&gt;
# “cTgainshaperab” (curve) which takes any value bewteen 0.70 and 0.90&lt;br /&gt;
# “retrab” which varies around 500.&lt;br /&gt;
I have added 3 more parameters (in the form of sliders) – hueref, chromaref and lumaref – hidden from the user but which are used to update the system in real time, to correctly take into account the reference “spot” values. Allowing those 3 parameters to vary brings stability and allows real time updates. Increasing the number of those “fantasy” parameters should not be necessary. These extra parameters are hidden to the user, and are only visible in the history.&lt;br /&gt;
&lt;br /&gt;
In addition, I had to add some empirical time delays, giving time to time… Time delay is used for example when the user modifies the curve (amplitude, number of inflection points).&lt;br /&gt;
&lt;br /&gt;
==Some specificities of the local mode (as compared to “Lab adjustments”)==&lt;br /&gt;
Hereafter are some useful informations for the user, often specific to the local mode.&lt;br /&gt;
&lt;br /&gt;
===Color and Light===&lt;br /&gt;
 * The algorithms used for luminance and contrast in local mode differ from the ones used in “Lab adjustments”, which may lead to differences in rendering.&lt;br /&gt;
* The luminance algorithm is made such that below -90 and down to -100 for “lightness”, it is possible to increase the image “darkness”, almost to the point of getting a luminance value close to 0. To accentuate this effect, “chrominance” can be decreased and “scope” increased.&lt;br /&gt;
* The inverse mode can be used for creating graduated frames. If “ligthness” is set to -100 and chrominance is reduced, the “frame border” will be black.&lt;br /&gt;
* For “luminance” and “contrast” (slider), there’s a choice among 2 algorithms: the first (default) one is close to the one in “Lab adjustments” while the second one, activated through “Lightness - Contrast ‘Super’” is close to the algorithm used for the L=f(L) “super” curve.&lt;br /&gt;
* Do not hesitate, as the case might be, to activate “Enhanced” or “Enhanced + chroma denoise” for in the “Global Quality:” combobox.&lt;br /&gt;
&lt;br /&gt;
====Curves====&lt;br /&gt;
* An L=f(L) or C=f(C) curves allow controlling the luminance and chrominance for each RT-spot as a function of luminance or chrominance.&lt;br /&gt;
* An L=f(H) curve allows controlling the luminance for each RT-spot as a function of tint.&lt;br /&gt;
* An H=f(H) curve allows controlling the tint for each RT-spot as a function of tint.&lt;br /&gt;
The curves are activated by selecting one of the two algorithms from the “Curves types” combobox:&lt;br /&gt;
* “Normal”: the curves – particularly the one that is the most difficult to manage, L=f(L) – use an algorithm close to the one used with the sliders (Normal mode),&lt;br /&gt;
* “Super”: using a new algorithm, which I think performs very well (it even surprised me the first time I used it).&lt;br /&gt;
&lt;br /&gt;
Caution: when the RT-spot resides in an area which is neutral, gray or very uniform, the artifacts introduced by the new algorithm (“Super” algorithm for the curve or the slider) may be impossible to get rid of. Use one of the 2 older algorithms to avoid that.&lt;br /&gt;
&lt;br /&gt;
===Exposure===&lt;br /&gt;
The “Exposure” module may look like the the one in global RGB mode, but:&lt;br /&gt;
* it works entirely in L*a*b* mode, hence the differences in rendering;&lt;br /&gt;
* there’s no “Lightness”, “Chroma” or “Contrast” slider, whose functions are already fullfilled in the “Color and Light” module;&lt;br /&gt;
* there’s only one “Contrast” curve, similar to the L=f(L) firm “Color and Light”. Of course its effect is different from “Tone curve” which works in RGB mode. If needed, 2 L=f(L) curveds can be activated, one in “Color and Light” and the other in “Exposure”.&lt;br /&gt;
&lt;br /&gt;
===Vibrance===&lt;br /&gt;
This module is similar to the main one (from Exposure tab).&lt;br /&gt;
&lt;br /&gt;
===Blur &amp;amp; Noise===&lt;br /&gt;
“Blur” is activated only when “Radius” =&amp;lt; 2.&lt;br /&gt;
By significantly lowering the default value of “Scope” and possibly checking “Blur luminance only”, it is possible to get a different amount of blur for the different tints.&lt;br /&gt;
Since October 2017, 3 methods are proposed:&lt;br /&gt;
* “Normal”: the shape detection algorithm has been improved, it is now closer to shape detection algorithm proposed in the other modules;&lt;br /&gt;
* “Inverse”: a simplified algorithm, which doesn’t make use of “Scope”. The inversion is coarse and doesn’t allow a fine separation between the affected and unaffected areas;&lt;br /&gt;
* “Symmetric”: this new algorithm uses the same processes as “Normal”, and adjusting “Scope” the user can target the process with more precison.&lt;br /&gt;
Caution: &lt;br /&gt;
* Using the “Inverse” mode will blur large portions of the image, which can not be corrected later on.&lt;br /&gt;
* The action of “Scope” may sometimes appear puzzling: for instance, in a portrait, the eyes (which of course differ from the skin) may be blurred if the value of “Scope” is too low.&lt;br /&gt;
&lt;br /&gt;
===Tone Mapping===&lt;br /&gt;
Caution when uniformly colored areas (sky, gray/neutral zones) have a similar tint to the area on which the RT-spot is placed. In cases where this leads to artifacts, set the “Iterations” slider to 0 in “Settings” &amp;gt; “Reduce artifacts – Improve algorithm”.&lt;br /&gt;
&lt;br /&gt;
===Retinex===&lt;br /&gt;
Compared to the standard “Retinex” module, the local “Retinex module has simplified controls, and is applied at the end of the pipeline instead of the beginning. Since mip version 10002, the “Transmission gain” is specific to each RT-spot.&lt;br /&gt;
&lt;br /&gt;
===Sharpening===&lt;br /&gt;
Only the “RL Deconvolution” algorithm is provided here.&lt;br /&gt;
&lt;br /&gt;
===Contrast by detail levels===&lt;br /&gt;
Compared to the main RGB mode module, this one has:&lt;br /&gt;
* 5 levels instead of 6,&lt;br /&gt;
* no slider for “skin tone” protection (not needed since the algorithm works locally on the RT-spot area),&lt;br /&gt;
* an additional “Chroma” slider.&lt;br /&gt;
&lt;br /&gt;
Caution when uniformly colored areas (sky, gray/neutral zones) have a similar tint to the area on which the RT-spot is placed. In cases where this leads to artifacts, set the “Iterations” slider to 0 in “Settings” &amp;gt; “Reduce artifacts – Improve algorithm”.&lt;br /&gt;
&lt;br /&gt;
===Denoise===&lt;br /&gt;
Compared to the main RGB mode module, this one has:&lt;br /&gt;
* only the wavelet tool working (no Fourier function, nor medians),&lt;br /&gt;
* less sliders and curves,&lt;br /&gt;
* the possibility to work differentially on fine or coarse noise for both luminance and chrominance noise.&lt;br /&gt;
&lt;br /&gt;
==Specific case : reduction of image defects (dirty sensor, red eyes, …)==&lt;br /&gt;
“Locallab” had not been thought with the idea of correcting small image defects. However, some visible, “photographically disturbing” defects may actually be tamed or even removed. Of course, this is not incompatible with other more specialized modules which could be introduced (or not) into “Locallab”… At least 3 existing modules can serve this purpose, alone or in combination, by adapting their use:&lt;br /&gt;
* “Color and Light” for spot-like defects;&lt;br /&gt;
* “Contrast by detail levels” for spread out defects;&lt;br /&gt;
* “Blur and Noise” as an optional complement (caution, this is a destructive action, use moderately).&lt;br /&gt;
&lt;br /&gt;
These modules can be used either on the main image (raw, TIFF,  …) or on a flat-field image.&lt;br /&gt;
&lt;br /&gt;
===Using the “Color and Light” module===&lt;br /&gt;
* Activate “Color and Light”&lt;br /&gt;
* A red eye removal tool equivalent can be obtained by framing closely around the eye – central circle zone centered on the eye’s red, spot handles close to the eye – low “Scope” value, then lowering “Lightness” and “Chrominance” to -100.&lt;br /&gt;
* The same idea allows reducing the “IR spot” kind of defect by framing closely around the defect – central circle zone centered on the defect, spot handles close to the defect area – then lowering “Chrominance” to taste, and if needed lowering the “scope” value.&lt;br /&gt;
* In some (simple) situations, a “dirty sensor” defect can be reduced, in particular in the case of “sensor grease”. It can be seen as stains or spots on a uniform background. To attenuate this, choose a tight framing of around the defect – central circle on the center of the defect (adapt the size of the RT-spot), drag the handles so that they are not too close to the border of the defect (this will make the transition less noticeable). Then: a) decrease “Transition” towards lower values; b) check “Lightness - Contrast “Super”; c) adjust “Lightness” and “Chrominance” as needed to bring the defect area closer to the unaffected area; d) if needed adjust slightly “Scope” to achieve the best result.&lt;br /&gt;
&lt;br /&gt;
===Using the “Contrast by detail levels” module===&lt;br /&gt;
When the sensor is dirty (grease), and when the affected area is large or if there are multiple small defects, “Contrast by detail levels” may be used, working as a sort of “wavelet” tool on luminance, and if needed on chrominance. In such cases: a) place the RT-spot on one of the stronger defects (adjust the size as needed); b) drag the handles so as to cover most of the affected area; c) set “Transition” to higher value; d) activate “Contrast by detail levels” and decrease the contrast of levels 3 and 4 (or lower); you can adjust the “Chroma” slider if needed.&lt;br /&gt;
&lt;br /&gt;
==Preferences options and settings==&lt;br /&gt;
Below is a list of the settings (already mentioned above in several places) which can be accessed from the “Preferences” dialog:&lt;br /&gt;
* In “Preferences” &amp;gt; “General” tab &amp;gt; “Local adjustments”, by checking the “Show spot delimiters” checkbox, an approximate zone delimitation is drawn which helps viewing the area affected by the RT-spot and its settings.&lt;br /&gt;
* If your images generally have low noise, you can set the default for “Global quality” to “Standard”, and get a significant speedup in processing time. This setting is found under “Preferences” &amp;gt; “Performance &amp;amp; Quality” tab &amp;gt; “Local adjustments”. The three choices for quality are selected from the “Local adjustments Quality method” combobox. Default is “Enhanced + chroma denoise”.&lt;br /&gt;
* Regarding “mip” files:&lt;br /&gt;
** the choice for “mip” files destination folder is set from “Preferences” &amp;gt; “Image processing” tab &amp;gt; “Mip Profiles”;&lt;br /&gt;
** in order to clean the generated “mip” profiles, go to “Preferences” &amp;gt; “File Browser” tab &amp;gt; “Cache Options” and click on the “Clear mip” button and/or “Clear pp3” – this is valid in the case where you chose to store “mip” files in the cache, otherwise if you chose to let RT write the “mip” files next to the input file, you will have to delete them manually. Note that the presence of older versions of “mip” and “pp3” files may lead to instability or even crashes of RawTherapee.&lt;br /&gt;
&lt;br /&gt;
==Processing time and memory use==&lt;br /&gt;
At image export time (output to JPG, TIFF…), for the “normal” mode, the algorithms compute the data only for in the RT-spot delimited areas, not for the whole image. Thus, processing time and memory stay reasonable. Note that of course, this will depend on the number of RT-spots, their size, and the type(s) of treatment done in these RT-spots.&lt;br /&gt;
&lt;br /&gt;
Excluding “Denoise” and “Sharpen”, processing time is in the order of a few tenths of a second per RT-spot, and memory use of a few hundred MB.&lt;br /&gt;
&lt;br /&gt;
Two settings have a strong influence on resource use:&lt;br /&gt;
    • “Denoise” which adds around 1 sec. of processing time, and 1 MB of memory use;&lt;br /&gt;
    • “Global quality: Enhanced + chroma denoise” which adds around 0.5 sec. And 0.6 MB.&lt;br /&gt;
These figures depend on the size of the RT-spot.&lt;br /&gt;
&lt;br /&gt;
==Future evolutions==&lt;br /&gt;
Besides usual tweaking, bug corrections, improvements (settings, user interface)… it would be desirable to improve the GUI with regards to the creation/selection/modification of individual RT-spots.&lt;br /&gt;
&lt;br /&gt;
From a programming point of view, it should be possible to improve code readability and maintainability, and to integrate all the “mip” files code parts (as done in “rgbproc.cc”) which currently are linearly integrated to void procedures in “improccoordinator.cc”, “dcrop.cc” and “simpleprocess.cc”.&lt;/div&gt;</summary>
		<author><name>Sguyader</name></author>
	</entry>
</feed>