
\graphicspath{{./figures/}}


\chapter{Specifying the contrast of images\label{chapMidway}}

 Midway image equalization means any method giving
   to a pair of images a similar histogram, while
maintaining  as much as possible their previous grey level dynamics. The comparison of two images is one of the main
goals of computer vision. The pair can be a stereo pair, two images of the same object (a painting for example),
multi-channel images of the same region, images of a movie, etc. Image comparison is perceptually greatly improved if
both images have the same grey level dynamics (which means, the same grey level histogram). Many image comparison
algorithms are based on grey level and take as basic assumption that intensities of corresponding points in both images
are equal.  However, this assumption is generally false for stereo pairs, and deviations from this assumption cannot
even be modeled by affine transforms \cite{cox1995dhw}. Consequently, if we want to compare visually and numerically
two images, it is useful to give them first the same dynamic range and luminance.


 In all of this applicative chapter the images  $u(\fxx)$ and $v(\fxx)$
are defined on a domain  which is the union of $M$ pixels. The area of each pixel is equal to 1. The images are
discrete in space and values: they attain values  in a finite set $\mathbb L$ and they are constant on each pixel of
the domain. We shall call such images {\it discrete images}. The piecewise constant interpolation is a very bad image
interpolation. It is only used here for a fast handling of image histograms. For other scopes, better interpolation
methods are of course necessary.
\begin{definition} Let $u$  be a discrete image. We call {\it cumulative histogram  of} $u$ the function $H_u: \mathbb
L\to \mathbb M:=[0,M]\cap \NN$  defined by
$$H_u(l)=:\hbox{\rm meas}(\{\fxx\mid u(\fxx)\leq l\}).$$
\end{definition}
This  cumulative histogram is a primitive of the {\it histogram} of the image $h(l)=\hbox{meas}(\{\fxx\mid
u(\fxx)=l\}).$ Figures \ref{figure3.4}, \ref{figure3.6} and the first line of Figure~\ref{marais}.
   show the
histograms of some images and their cumulative  histograms. In fact Figure \ref{figure3.7} shows first  the histogram
and then the modified histogram after a contrast change has been applied. These experiments illustrate the robustness
of image relevant information to contrast changes and even to the removal of some level sets, when the contrast change
is flat on an interval. Such experiments suggest that one can {\it specify} the histogram of a given image by applying
the adequate contrast change. Before proceeding, we have to define the pseudo-inverses of a discrete function.

\begin{proposition} \label{defpseudoinversediscrete}Let $\varphi:\;\mathbb L\to\mathbb M$ be a nondecreasing function from a finite set of  values into
another. Define two pseudo-inverse functions for $\varphi:$
$$\varphi^{(-1)}(l):=\inf\{s\mid \varphi(s)\geq l\} \hbox{ and }\varphi^{((-1))}(l):=\sup\{s\mid \varphi(s)\leq l.\}$$
Then one has the following equivalences:
\begin{equation}\label{equivalencespseudoinverse}
\varphi(s)\geq l\Leftrightarrow s\geq \varphi^{(-1)}(l),\quad \varphi(s)\leq l\Leftrightarrow s\leq \varphi^{((-1))}(l)
\end{equation}
and the identity
\begin{equation}\label{inversiontoujours}
(\varphi^{(-1)})^{((-1))}=\varphi.
\end{equation}
\end{proposition}

\begin{proof}  The implication $\varphi(s)\geq l\Rightarrow s\geq \varphi^{(-1)}(l)$ is just the definition of
$\varphi^{(-1)}$. The converse implication is due to the fact that the infimum on a a finite set is attained. Thus
$\varphi(\varphi^{(-1)}(l))\geq l$ and therefore $s\geq \varphi^{(-1)}(l)\Rightarrow \varphi(s)\geq l.$ The identity
\eqref{inversiontoujours} is a direct consequence of the equivalences \eqref{equivalencespseudoinverse}. Indeed,
$$s\leq (\varphi^{(-1)})^{((-1))}(l)\Leftrightarrow \varphi^{(-1)}(s)\leq l \Leftrightarrow s\leq \varphi(l).$$
\end{proof}

\begin{exercise} Prove that if $\varphi$ is  increasing,  $\varphi^{(-1)}\circ \varphi(l)=l$ and
$\varphi^{((-1))}\circ\varphi(l)=l$. If $\varphi$ is surjective, $\varphi\circ\varphi^{(-1)}=l$ and
$\varphi\circ\varphi^{((-1))}(l)=l$. \finex
\end{exercise}


\begin{proposition}\label{changementdefonctionderepartition}
  Let $\varphi$  be a discrete contrast change and $u$ a digital image.  Then
  $$H_{\varphi(u)}=H_u\circ \varphi^{((-1))}.$$
\end{proposition}

\begin{proof} By \eqref{equivalencespseudoinverse},
 $\varphi(u)\leq l\Leftrightarrow u\leq
\varphi^{((-1))}(l).$ Thus by the definitions of $H_u$ and  $H_{\varphi(u)}$,
$$H_{\varphi(u)}(l)=\hbox{meas}(\{\fxx\mid\varphi(u) \leq l\})=\hbox{meas}(\{\fxx\mid u(\fxx)\leq
\varphi^{((-1))}(l)\})=H_u\circ\varphi^{((-1))}(l).$$
\end{proof}
   Let $G:\mathbb L \to \mathbb M:=[0,1,\dots, M]$ be any discrete nondecreasing
  function. Can we
 find a contrast change
 $\varphi: \mathbb L\to \mathbb L$ such that the cumulative histogram  of $\varphi(u)$,  $H_{\varphi(u)}$ becomes equal
  to $G$? Not quite: if for instance $u$ is constant its
 cumulative histogram is a one step function and  Proposition  \ref{changementdefonctionderepartition} implies that $H_{\varphi(u)}$
 will also  be a one step function. More generally if $u$ attains $k$  values, then $\varphi(u)$  attains   $k$ values
 or less.
 Hence its cumulative histogram is a step function with $k+1$  steps.  Yet, at least formally, the functional
 equation given by Proposition \ref{changementdefonctionderepartition},
   $H_u\circ \varphi^{-1}=G$, leads
to $\varphi=G^{-1}\circ H_u$. We know that we cannot get true  inverses but we can involve pseudo-inverses. Thus, we
are led to the following   definition:

\newpage
\begin{definition}\label{specification}
Let $G:\mathbb L\to \mathbb M$ be a  nondecreasing function. We call specification of $u$ on the cumulative histogram
$G$ the image
$$\tilde u:= G^{((-1))}\circ H_u(u).$$
\end{definition}

\begin{exercise} Prove that if $G$ and $H_u$ are one to one, then the cumulative histogram of $\tilde u$ is
$G$. Is it enough to assume that $H_u$ is one to one?\finex
\end{exercise}
%
%\begin{proof}
%%Using \eqref{equivalencespseudoinverse},  one has
%$$\tilde u\leq l\Leftrightarrow G^{(-1)}\circ H_u(u)\leq l \Leftrightarrow H_u(u)\leq G(l)\Leftrightarrow
%u\leq H_u^{((-1))}\circ G(l).$$ Thus if $H_u$ is surjective, by Proposition \ref{defpseudoinversediscrete} $$H_{\tilde
%u}(l)=\text{meas}(\{\fxx\mid u(\fxx)\leq H_u^{((-1))}\circ G(l)\}) =H_u\circ H_u^{((-1))}\circ G(l)=G(l).$$
%\end{proof}




\begin{definition} Let, for $l\in [0,L]\cap\natural$,  $G(l)=\lfloor\frac {M}{L}l\rfloor$, where $\lfloor r\rfloor$ denotes the largest integer
 smaller than $r$. Then
 $\tilde u:= G^{((-1))}\circ H_u(u)$ is called the {\rm uniform equalization of $u$.} If $v$  is another discrete image and
one takes $G=H_v$, $\tilde u:=H_v^{((-1))}\circ H_u(u)$  is called the {\rm specification of $u$  on $v$.}
\end{definition}
 When $H_u$ is one to one, one can reach by applying a contrast change to $u$  any specified cumulative histogram $G$.
Otherwise, the above definitions do the best that can be expected and are actually quite efficient. For instance in the
``marshland experiment" (Figure \ref{marais}) the equalized histogram and its cumulative histogram are displayed on the
second row. The cumulative histogram is very close to its goal, the linear function. The equalized histogram does  not
look flat but a sliding average of it would look almost flat.

\begin{figure}[h]\centering{
\includegraphics[width=5cm]{marais_carre}
\includegraphics[width=3cm, height=3cm]{marais_histo}
\includegraphics[width=3cm, height=3cm]{marais_histo_cumul}\\
\includegraphics[width=5cm]{marais_eq_carre}
\includegraphics[width=3cm, height=3cm]{marais_eq_histo}
\includegraphics[width=3cm, height=3cm]{marais_eq_histo_cumul}\\
\includegraphics[width=5.5cm]{marais_extrait}
\includegraphics[width=5.5cm]{marais_eq_extrait}
} \caption{\em  First row: Image $u$, the corresponding grey level histogram $h_u$, and the cumulative histogram $H_u$.
Second row: Equalized image $H_u(u)$, its histogram and its cumulative histogram. In the discrete case, histogram
equalization flattens the histogram as much as possible.  We see on this example that image equalization can be
visually harmful. In this marshland image, after equalization, the water is no more distinguishable from the
vegetation.  The third row shows a zoom  on the rectangular zone, before and after equalization. } \label{marais}
\end{figure}
Yet it is quite dangerous to specify the histogram of an image with an arbitrary histogram specification. This fact is
illustrated in Figures \ref{marais} and \ref{piano} where a uniform equalization  erases existing textures by making
them too flat (Figure \ref{marais}) but also enhances the quantization noise in low contrasted regions and produces
artificial edges or textures (see Figure~\ref{piano}).


\begin{figure}
 \includegraphics[width=6cm]{piano}
\includegraphics[width=6cm]{piano_eq}
\caption{\em Effect of histogram equalization on the quantization noise. On the left, the original
 image. On the right, the same image after histogram equalization. The effect of this equalization on the
 dark areas (the piano, the left part of the wall), which are low contrasted, is perceptually dramatic. We see many more details
 but the quantization noise has been exceedingly amplified.}
\label{piano}
\end{figure}




\section{Midway equalization}


We have seen that if one specifies $u$ on $v$, then $u$ inherits roughly  the histogram of $v$. It is sometimes more
adequate to bring the cumulative histograms  of $u$ and $v$ towards a  cumulative histogram which would be ``midway"
between both. Indeed, if we want to compare visually and numerically two images, it is useful to give them first the
same dynamic range and luminance. Thus we wish:
\begin{itemize}
\item \indent From two images $u$ and $v$,
construct by contrast changes two images $\tilde{u}$ and $\tilde{v}$, which have a similar cumulative histogram.

\item This common cumulative histogram $h$ should stand ``midway" between the previous cumulative histograms of
$u$ and $v$, and be as close as possible to each of them. This treatment must avoid to favor one cumulative histogram
rather than the other.
\end{itemize}






 \nada{In the next section we shall discuss some formal requirements leading to the definition of the midway
cumulative histogram.


\subsection{Axioms of midway equalization}
  We search for two contrast changes $\ph_u$ and $\ph_v$ such that
$\ph_u(u)$ and $\ph_v(v)$ have the same histogram. Thus, formally (see Proposition
\ref{changementdefonctionderepartition}),
 $${\ph_u}^{-1} \circ \ph_v={H_u}^{-1} \circ H_v.$$ In order to select the
right method, two axiomatic approaches are possible. A very intuitive way to specify axiomatically a method is to state
what the expected result should be for a short list of key examples. Here, we shall consider a very simple particular
case: Assume that $u$ and $v$ represent the same image up to a contrast change, namely $u=f(u_0)$ and $v=g(u_0)$, where
$f$ and $g$ are  increasing functions.


\medskip
\noindent \textit{Axiom 1:} the  intermediate image between $u$ and $v$ is a direct average function of $f(u)$ and
$g(u)$. The average function is  independent of $f$ and $g$.

\medskip
This axiom means that there exists a function $F:[0,1]^2\rightarrow [0,1]$, such that for every pair of images $(u,v)$,
 the inverse of their intermediate cumulative histogram will be $F(H_u^{-1},H_v^{-1})$.  It can also be interpreted
  by saying that the operator computing the intermediate histogram acts independently on the level sets of rank $\lambda$.

A second general axiom can possibly be added, concerning the simple case where $u$ and $v$ differ by a constant.

\medskip
\noindent \textit{Axiom 2:}   If $v=u+\lambda$, then $\ph_u(u)=\ph_v(v)=u+\frac{\lambda}{2}$.
\medskip



\medskip
{\bf Analysis of Axioms 1 \& 2: the Inverse Average Equalization.}
 \noindent If the axioms $2$ and $3$ are satisfied, the
axiom $3$ implies that:
$$\forall x,\; \forall \lambda,\;F(x+\lambda,x)=x+\frac{\lambda}{2},$$
which yields  $F(x,y)=\frac{x+y}{2},\; \forall (x,y) \in [0,1]^2$.
 Thus, we have:
\begin{proposition}
The only intermediate image between $f(u)$ and $g(u)$ satisfying the axioms $2$ and $3$ is $\frac{f(u)+g(u)}{2}$.
\end{proposition}

\noindent The intermediate cumulative histogram constructed in this way is
\begin{eqnarray*}
H_{\textit{new}}&=&H \circ (\frac{f+g}{2})^{-1}=(\frac{f \circ H^{-1}+g \circ H^{-1}}{2})^{-1}\\
&=&(\frac{{H_u}^{-1}+{H_v}^{-1}}{2})^{-1}.\\
\end{eqnarray*}
The general method deduced from the previous proposition will be called \textit{midway equalization}. The contrast
changes involved are:
$$\ph_u=\frac{id+{H_u}^{-1}\circ H_v}{2} \;\text{  and  }\; \ph_v=\frac{id+{H_v}^{-1}\circ H_u}{2}.$$


} % FIN DE NADA



\begin{definition}\label{definitionmidwaycumulativehistogram} Let $u$ and $v$ be two discrete images.
 Set $$\Phi:= \frac 12\left(H_u^{(-1)}+H_v^{(-1)}\right).$$
 We call {\rm midway cumulative histogram}
of $u$ and $v$ the function
\begin{equation}G:= \Phi^{((-1))}=\left(\frac 12(H_u^{(-1)}+H_v^{(-1)})\right)^{((-1))}\label{specificationdeladistribution}
\end{equation}
and ``midway specifications" of $u$ and $v$ the functions $\tilde u:=\Phi\circ H_u(u)$ and $\tilde v:=\Phi\circ
H_v(v).$
 \end{definition}



\begin{exercise}
Let $u$ and $v$ be two constant  images, whose values are  $a$ and $b$.  Prove that their ``midway" function is the
right one, namely a function $w$ which is constant and equal to $\frac{a+b}2$.\finex
  \end{exercise}


\begin{exercise} Prove that if we take as a definition of the midway histogram
$$G:=\left(\frac 12(H_u^{((-1))}+H_v^{((-1))})\right)^{(-1)},$$ then for two constant images $u=a$ and
$v=b$   the midway image is constant and equal to $[1/2(a+b)-1]$.  This proves that Definition
\ref{definitionmidwaycumulativehistogram} is better. \finex
\end{exercise}

\begin{exercise} Prove that if  $u$  is a discrete image and $f$ and $g$ two nondecreasing functions, then the midway
image of $f(u)$ and $g(u)$ is $\frac{f(u)+g(u)}2$. \finex
\end{exercise}

  \begin{exercise}
  If we want the ``midway" cumulative histogram $H$ to be a compromise between $H_u$ and $H_v$, the
  most elementary function that we could imagine is their average, which amounts to average their histograms as well.
   However, the following example proves
  that this idea is not  judicious at all.

Consider two images whose histograms are ``crenel" functions on two disjoint intervals, for instance $u(\fxx):= ax$,
$v(\fxx)=bx+c$.  Compute $a, b, c$ in such a way that $h_u$  and $h_v$ have disjoint supports. Then compute the
specifications of $u$ and $v$ on the mean cumulative histogram  $G:=\frac {H_u+H_v}2$. Compare with their
specifications on the midway cumulative histogram. \finex
\end{exercise}

\section{Midway equalization on image pairs}

\subsection*{Results on a stereo pair}


The top of Figure~\ref{toulouse} shows a pair of aerial images in the region of Toulouse. Although the angle variation
between both views is small, and the photographs are taken at nearly the same time, we see that the lightning
conditions vary significantly (the radiometric differences can also come from a change in camera settings). The second
line shows the result of the specification of the histogram of each image on the other one. The third line shows both
images after equalization.

\begin{figure}\centering{
\includegraphics[width=6.0cm]{img11}
\includegraphics[width=6.0cm]{img12}\\
\vspace{0.2cm}
 \includegraphics[width=6.0cm]{img11sp12}
\includegraphics[width=6.0cm]{img1211}\\
\vspace{0.2cm}
\includegraphics[width=6.0cm]{img11ds}
\includegraphics[width=6.0cm]{img12ds}}
\caption{Stereo pair: two pieces of aerial images of a region of Toulouse. Same images after specification of their
histograms on each other (left: the histogram of
 the first image has been specified on the second, and right: the histogram of the second image has been specified
  on the first). Stereo pair after midway equalization.} \label{toulouse}
\end{figure}


If we scan  some image details, as illustrated on Figure~\ref{extraits}, the damages caused by a direct specification
become obvious. Let us specify the darker image on the brightest one. Then the information loss, due to the reduction
of dynamic range, can be detected in the brightest areas. Look at the roof of the bright building in the top left
corner of the image (first line of Figure~\ref{extraits}): the chimneys project horizontal shadows on the roof. In the
specified image, these shadows have almost completely vanished, and we cannot even discern the presence of a chimney
anymore. In the same image after equalization, the shadows are still entirely recognizable, and their size reduction
remains minimal. The second line of Figure~\ref{extraits} illustrates the same phenomenon, observed in the bottom
center of the image. The structure present at the bottom of the image has completely disappeared after specification
and remains visible after midway equalization. These examples show  how visual information can be lost by specification
and how  midway algorithms reduce significantly this loss.



\begin{figure}[h]
\centering{
\includegraphics[width=9.0cm]{extrait1}
%\\\includegraphics[width=9.0cm]{extrait2}
}
\caption{\em Extracts from the stereo pair shown on Figure~\ref{toulouse}. From left to right: in the original image,
in the specified one, in the original image after midway equalization. Notice that no detail is lost in the midway
image, in contrast with the middle image.} \label{extraits}
\end{figure}







\subsection*{Multi-Channel images}
The top of Figure~\ref{multi} shows two pieces of multi-channel images of Toulouse. The first one is extracted from the
blue channel, and the other one from the infrared channel. The second and third line of the same figure show the same
images after midway equalization.  The multichannel images have the peculiarity to present contrast inversions : for
instance, the trees appear to be darker than the church in the blue channel, and are naturally brighter than the church
in the infrared channel. The midway equalization being limited to
 increasing contrast changes, it obviously cannot handle these contrast inversions.  In spite of these contrast inversions, the results remain visually good, which underlines the robustness of
 the method gives globally a good equalization.
\begin{figure}
\centering{
\includegraphics[width=4.0cm]{toul0}
\includegraphics[width=4.0cm]{toul3}\\
\includegraphics[width=4.0cm]{toul0v3_p512}
\includegraphics[width=4.0cm]{toul3v0_p512}\\}
 \caption{\em First line: two images of Toulouse (blue and infrared channel). Second line:    same images after midway
  equalization.} \label{multi}
\end{figure}


\subsection*{Photographs of  the same painting}
The top of Figure~\ref{meduse} shows two different snapshots of the same painting, \textit{Le Radeau de la
M\'{e}duse}\footnote{Musée du Louvre, Paris.}, by Th\'{e}odore G\'{e}ricault (small web public versions). The second
one is brighter and seems to be damaged at the bottom left. The second line
 shows the same couple after midway equalization.  Finally, the last line of Figure~\ref{meduse} shows the difference between
   both images after equalization. We see clear differences around the edges, due to the fact that
   the original images are not completely similar from the geometric point of view.

%\onecolumn
\begin{figure}
\centering{
\includegraphics[width=6.0cm]{meduse}
\includegraphics[width=6.0cm]{meduse5}\\
\vspace{0.2cm}
\includegraphics[width=6.0cm]{meduse1_5}
\includegraphics[width=6.0cm]{meduse5_1}\\
\vspace{0.2cm}
 \includegraphics[width=6.0cm]{diff_meduse}}
 \caption{Two shots of the \textit{Radeau de la M\'{e}duse, by G\'{e}ricault}. The same images after midway
equalization. Image of the difference between both images after equalization.  The  boundaries appearing in the
difference are mainly due to the small geometric distortions between the initial images.}\label{meduse}
\end{figure}


\subsection{Movie equalization}

One can define a midway cumulative histogram to an arbitrary number of images. This is extremely useful for the removal
of flicker in old movies. Flicker has multiple causes, physical, chemical or numerical. The  overall contrast of
successive images of the same scene in a movie oscillates, some images being dark and others bright. Our  main
assumption is that image level sets are globally preserved from one image to the next, even if their level evolves.
This  leads to the adoption of a movie equalization method preserving globally all level sets of each image. We deduce
from Theorem \ref{existscontrastchange} in the previous chapter that the correction must be a global contrast change on
each image. Thus the only left problem is to {\it specify} a common cumulative histogram  (and therefore a common
histogram) to all images of a given movie scene. Noticing that the definition of $G$ in
\eqref{specificationdeladistribution} for two images simply derives from a mean,
 its
generalization is easy. Let us denote $u(t,\fxx)$ the movie (now a discrete time variable has been added) and by $H^t$
the cumulative histogram function of $\fxx\to u(t,\fxx)$ at time $t$. Since flicker is localized in time, the idea is
to define a time dependent cumulative histogram function $K_t^h$ which will be the ``midway" cumulative histogram of
the cumulative histograms in an interval $[t-h, t+h]$.  Of course the linear scale space theory of Chapter
\ref{ChapCOIFTTHE} applies here. The ideal average is gaussian. Hence the following definition.

\begin{definition} \label{gaussianmidway}
Let $u(t,\fxx)$ be a movie and denote by $H_t$ the cumulative histogram of $u(t): \fxx\to u(t,\fxx).$ Consider a
discrete version of the 1-D gaussian $G_h(t)=\frac{1}{(4\pi h)^{\frac 12}}e^{-\frac {t^2}{4h}}$. Set
$$\Phi_{(t,l)}:=\int G_h(t-s) (H_s^{(-1)})(l)ds.$$
 We call ``midway gaussian cumulative histogram at scale $h$" of the movie $u(t,\fxx)$
the time dependent cumulative histogram
\begin{equation}
\mathbb G_{(t,l)}:= \Phi_{(t,l)}^{((-1))}= \left(\int G_h(t-s)
(H_s^{(-1)})(l)ds\right)^{((-1))}\label{formulamidwaygaussian}
\end{equation}
and ``midway specification" of the movie $u(t)$ the function $\tilde u(t):=\Phi\circ H_{u(t)}(u(t))$. If $H_{u(t)}$ is
 surjective, then $\tilde u(t)$ has $G_{(t,l)}$ as common cumulative histogram.

\end{definition}
Notice that this is a straightforward extension of Definition \ref{definitionmidwaycumulativehistogram}.






\begin{figure}[htbp]
\centering{
\includegraphics[width=3.8cm]{charlot0}
\includegraphics[width=3.8cm]{charlot40}
\includegraphics[width=3.8cm]{charlot80}\\
\includegraphics[width=3.8cm]{out_charlot0}
 \includegraphics[width=3.8cm]{out_charlot40}
\includegraphics[width=3.8cm]{out_charlot80}\\
 \includegraphics[width=7cm]{moyennejob}}
\caption{\em (a) Three images of Chaplin' s film \textit{His New Job}, taken at equal intervals of time. This extract
of the film suffers from a severe real flicker. (b) Same images after the Scale-Time Equalization at scale $s=100$. The
flicker observed before has globally decreased. (c) Evolution of the mean of the current frame in time and at three
different scales. The most oscillating line is the mean of the original sequence. The second one is the mean at scale
$s=10$. The last one, almost constant, corresponds to the large scale $s=1000$. As expected   the mean function is
smoothed by the heat equation.} \label{job}
\end{figure}
The implementation and experimentation is easy. We simply show in Figure \ref{job} three images of Chaplin' s film
\textit{His New Job}, taken at equal intervals of time. This extract of the film suffers from a severe real flicker.
This flicker is corrected at the  scale where, after gaussian midway equalization, the image mean becomes nearly
constant through the sequence. The effects of this equalization are usually excellent. They are easily extended to
color movies by processing each channel independently.

\nada{
\begin{figure}[htbp]
\centering{
\includegraphics[width=3.5cm]{charlot2_71}
\includegraphics[width=3.5cm]{charlot2_80}
\includegraphics[width=3.5cm]{charlot2_101}\\

\includegraphics[width=3.5cm]{out_charlot2_72}
\includegraphics[width=3.5cm]{out_charlot2_081}
\includegraphics[width=3.5cm]{out_charlot2_102}}
\caption{\em Top: Three images of Chaplin's film \textit{The Cure}, taken at equal interval of time. This part of the
film presents a strong real flicker. Some images in particular are very dark and low contrasted. Bottom: Same images
after a scale-time equalization at a large scale. The flicker has almost vanished.} \label{cure}
\end{figure}
}

\section{Comments and references}

\paragraph*{Histogram specification}

  As we have seen \textit{histogram specification} \cite{gonzalez1987dip}
  can be judicious if both images have the same kind of dynamic
  range. For the same reason as in
  equalization,  this method can also product contouring artifacts.
 The midway theory is essentially based on Julie Delons' PhD and papers \cite{delon2004mie}, \cite{delon2006mav} where
she defines two  midway histogram interpolation methods. One of them, the {\it square root} method involves the
definition of a square root of any nondecreasing function $g$, namely a function $g$ such that $f\circ f=g$.
  Assume that $u$ and $v$ come from the same image (this intermediate image is unknown), up to two contrast changes $f$
  and $f^{-1}$.
 The function $f$ is unknown, but satisfies formally the equality $ H_u \circ f =H_v \circ f^{-1}$. Thus
$${H_u}^{-1} \circ H_v=f \circ f.$$
It follows that the general method consists  in building an increasing function $f$ such that $f \circ f = {H_u}^{-1}
\circ H_v$ and replacing $v$ by  $f(v)$ and $u$ by $f^{-1}(u)$. This led  Delon \cite{Delon} to call this new histogram
midway method, the ``square root" equalization. The  midway interpolation developed in this chapter uses mainly J.
Delon's second definition of the midway cumulative histogram as the harmonic mean of the cumulative histograms
 of both images. This definition is preferable to the square root. Indeed, both definitions yield very similar
results but the harmonic mean extends easily to an arbitrary number of images and in particular to movies
\cite{delon2006mav}. The Cox, Roy and Hingorani algorithm defined in \cite{cox1995dhw} performs a midway equalization.
They called their algorithm ``Dynamic histogram warping" and its aim is to give a common cumulative histogram (and
therefore a common histogram) to a pair of images. Although their method is presented as a dynamic algorithm, there is
a very simple underlying formula, which is the harmonic mean of cumulative histograms discovered by  Delon
\cite{delon2004mie}.



\ifodd\count0
    \clearpage
    \leavevmode
    \thispagestyle{empty}
    \clearpage
\else\relax \fi
