Commit fd928833 authored by Fabian Nuraddin Alexander Gabel's avatar Fabian Nuraddin Alexander Gabel 💬
Browse files

Merge branch 'dev' into 'master'

update notes

See merge request !17
parents 4f35e1b3 770cf6bc
Pipeline #122436 passed with stage
in 1 minute and 51 seconds
# Created by https://www.toptal.com/developers/gitignore/api/latex,linux,windows,python,matlab,R
# Edit at https://www.toptal.com/developers/gitignore?templates=latex,linux,windows,python,matlab,R
#
ex??.*
ex??_live.*
### LaTeX ###
## Core latex/pdflatex auxiliary files:
......
......@@ -6,6 +6,9 @@ mathematical_image_processing:
- sed -i -e "s/gitSHA/$CI_COMMIT_SHORT_SHA/" -e "s/gitREF/$CI_COMMIT_REF_NAME/" skript_komplett.tex
- sed -i -e "s/GitSHA/$CI_COMMIT_SHORT_SHA/" -e "s/GitREF/$CI_COMMIT_REF_NAME/" tex_en/title_en.tex
- latexmk -pdf skript_komplett.tex
environment:
name: skript_komplett/$CI_COMMIT_REF_NAME
url: $CI_PROJECT_URL/-/jobs/$CI_JOB_ID/artifacts/raw/skript_komplett.pdf
artifacts:
paths:
- skript_komplett.pdf
......
# Custom dependency and function for nomencl package
add_cus_dep( 'nlo', 'nls', 0, 'makenlo2nls' );
sub makenlo2nls {
system( "makeindex -s nomencl.ist -o \"$_[0].nls\" \"$_[0].nlo\"" );
}
# Ablauf MathBV im WiSe 2019/20
## Woche 1
- [ ] VL Mo, 14.10. **mit Laptop**: Inhaltsüberblick, Bild, diskr. $\leftrightarrow$ kont.
- [ ] Ü Do, 17.10.: Matlab crash course (Pool)
## Woche 2
- [ ] VL Mo, 21.10.: diskret $\leftrightarrow$ kontinuierlich, Histogramm, Kontrastverbesserung
- [ ] VL Do, 24.10.: s/w-Konvertierung
## Woche 3
- [ ] VL Mo, 28.10.: Morpholog. Op., Rauschen, Korrelation
- [ ] Ü Do, 31.10. $\to$ 4.11.: Blatt 1
## Woche 4
- [ ] VL Mo, 04.11.: Faltung, Korrelation vs Faltung
- [ ] VL Do, 07.11.: optimaler 5-Punkt-Filter, Frequenzraumfilter, Fouriertrafo
## Woche 5
- [ ] VL Mo, 11.11. **mit Laptop**: Eigenschaften der FT, lowpass = Faltung mit sinc
- [ ] Ü Do, 14.11.: Blatt 2
## Woche 6
- [ ] VL Mo, 18.11.: Skalierung von Masken, Glättungs- vs. Kontrastfilter, Wiederholtes Glätten $\to$ Diffusion
- [ ] VL Do, 21.11.: Perona-Malik-Diffusion
## Woche 7
- [ ] VL Mo, 25.11. **mit Laptop**: bilaterale Filter, ~~Entrauschen mittels Variationsrechnung~~ *Feueralarm*
- [ ] Ü Do, 28.11.: Blatt 3
## Woche 8
- [ ] VL Mo, 02.12.: Entrauschen mittels Variationsrechnung
- [ ] VL Do, 05.12.: Kantenerkennung
## Woche 9
- [ ] VL Mo, 09.12.: Laplace-Schärfen, kantenverstärkende Diff., Entfalten ist schlecht gestellt,
- [ ] Ü Do, 12.12.: Blatt 4
## Woche 10
- [ ] VL Mo, 16.12.: Entfalten mit Regularisierung, Inpainting
- [ ] VL Do, 19.12.: Inpainting, Segmentierung Beleuchtungsausgleich
---
## Weihnachtspause
---
## Woche 11
- [ ] VL Mo, 06.01.: Segmentierung Mumford-Shah-Funktional
- [ ] Ü Do: Blatt 5
## Woche 12
- [ ] VL Mo, 13.01.: Registrierung
- [ ] VL Do, 16.01.: Registrierung, Mathematischer Nachschlag
## Woche 13
- [ ] VL Mo, 20.01.: Mathematischer Nachschlag
- [ ] Ü Do, 23.01.: Blatt 6
## Woche 14
- [ ] VL Mo, 27.01.: Mathematischer Nachschlag
- [ ] VL Do, 30.01.: Rückblick aufs Semester
\ No newline at end of file
......@@ -2,8 +2,22 @@
Lecture Notes for the course "Mathematical Image Processing"
## Newest Versions
## Branches and Versions
`master` [![](https://collaborating.tuhh.de/e-10/teaching/mathematical-image-processing/lecture-notes/-/jobs/artifacts/master/raw/update.svg?job=dynamic_badge)]([https://collaborating.tuhh.de/e-10/teaching/mathematical-image-processing/lecture-notes/-/jobs/artifacts/master/dev/skript_komplett.pdf?job=mathematical_image_processing])
Download the latest artifacts by clicking on the ![](https://img.shields.io/badge/red-red) or ![](https://img.shields.io/badge/blue-blue) badge in the **Latest Artifacts** column.
The "Live Version" contains modification of the content to make the notes usable for live annotations during the lecture.
`dev` [![](https://collaborating.tuhh.de/e-10/teaching/mathematical-image-processing/lecture-notes/-/jobs/artifacts/dev/raw/update.svg?job=dynamic_badge)]([https://collaborating.tuhh.de/e-10/teaching/mathematical-image-processing/lecture-notes/-/jobs/artifacts/dev/dev/skript_komplett.pdf?job=mathematical_image_processing])
* `master` has been published to Stud.IP.
* `dev` contains the latest changes and is merged into master regularly.
Clicking on the badges of the **Modification Date** column takes you to the source files of the selected branch.
| Branch | Latest Artifacts | Modification Date |
| ------ | --------------- | ----------------- |
| [`master`](https://collaborating.tuhh.de/e-10/teaching/mathematical-image-processing/lecture-notes/-/tree/master) | [![](https://img.shields.io/badge/Download-Stud.IP_Version-red)](https://collaborating.tuhh.de/e-10/teaching/mathematical-image-processing/lecture-notes/-/jobs/artifacts/master/raw/skript_komplett.pdf?job=mathematical_image_processing) [![](https://img.shields.io/badge/Download-Live_Version-blue)](https://collaborating.tuhh.de/e-10/teaching/mathematical-image-processing/lecture-notes/-/jobs/artifacts/master/raw/skript_live.pdf?job=live_skript)| [![](https://collaborating.tuhh.de/e-10/teaching/mathematical-image-processing/lecture-notes/-/jobs/artifacts/master/raw/update.svg?job=dynamic_badge)](https://collaborating.tuhh.de/e-10/teaching/mathematical-image-processing/lecture-notes/-/tree/master)
| [`dev`](https://collaborating.tuhh.de/e-10/teaching/mathematical-image-processing/lecture-notes/-/tree/dev) | [![](https://img.shields.io/badge/Download-Stud.IP_Version-red)](https://collaborating.tuhh.de/e-10/teaching/mathematical-image-processing/lecture-notes/-/jobs/artifacts/dev/raw/skript_komplett.pdf?job=mathematical_image_processing) [![](https://img.shields.io/badge/Download-Live_Version-blue)](https://collaborating.tuhh.de/e-10/teaching/mathematical-image-processing/lecture-notes/-/jobs/artifacts/dev/raw/skript_live.pdf?job=live_skript) | [![](https://collaborating.tuhh.de/e-10/teaching/mathematical-image-processing/lecture-notes/-/jobs/artifacts/dev/raw/update.svg?job=dynamic_badge)](https://collaborating.tuhh.de/e-10/teaching/mathematical-image-processing/lecture-notes/-/tree/dev)
## References
The dynamic badges are created using [anybadge](https://github.com/jongracecox/anybadge), see the `.gitlab-ci.yml` file for details.
Static badges are provided by [shields.io](https://shields.io/).
......@@ -53,6 +53,8 @@
\newcommand{\pbpres}{\ifpresent\pagebreak\fi} % pagebreak nur in Präsentation erzwingen
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\VL}[1]{\ifpresent\marginpar{\textcolor{blue}{\fbox{$\stackrel{\text{\bf lec#1}}{\stackrel{\downarrow}{\rule{4mm}{1pt}}}$}}}\fi}
%% margin comment: end of lecture x
\newcommand{\norm}[1] {
\left\lVert #1 \right\rVert
......@@ -385,3 +387,5 @@ tabsize=3}
%Caligraphic
\newcommand{\cF}{\mathcal{F}}
\newcommand{\BF}{\operatorname{BF}}
\renewcommand{\nomname}{List of Symbols}
......@@ -3,10 +3,13 @@
\usepackage[british]{babel} %vorher german
\usepackage{lmodern}
\usepackage[refpage]{nomencl}
\def\pagedeclaration#1{, \hyperlink{page.#1}{\nobreakspace#1}}
\usepackage{amsmath,amsthm,amssymb}
\usepackage{mathtools}
\usepackage{aligned-overset}
\usepackage[useregional]{datetime2}
\usepackage{adjustbox}
\usepackage{enumitem}
%\usepackage{enumerate}
......@@ -81,4 +84,5 @@
\usetikzlibrary{intersections,through,backgrounds}
\usetikzlibrary{matrix}
\usetikzlibrary{arrows}
\makenomenclature
\makeindex
......@@ -24,17 +24,33 @@
%
\include{tex_en/chap1_en} %
\include{tex_en/chap2_en}
\include{tex_en/chap2_ex}
\include{tex_en/chap3_en}
\include{tex_en/chap3_ex}
\include{tex_en/chap4_en}
\include{tex_en/chap4_ex}
\include{tex_en/chap5_en}
\include{tex_en/chap5_ex}
\include{tex_en/chap6_en}
\include{tex_en/chap6_ex}
\include{tex_en/chap7_en}
\include{tex_en/chap7_ex}
\include{tex_en/chap8_en}
\include{tex_en/chap8_ex}
\include{tex_en/chap9_en}
\include{tex_en/chap9_ex}
\include{tex_en/chap10_en}
\include{tex_en/chap10_ex}
\include{tex_en/chap11_en}
\include{tex_en/chap11_ex}
%\include{tex_en/appendix} %don't include appendix yet
\include{tex_en/biblio}
\newpage
\phantomsection
\addcontentsline{toc}{chapter}{List of Symbols}
\printnomenclature
\newpage
\phantomsection
\addcontentsline{toc}{chapter}{Index}
\printindex
\else
......@@ -49,7 +65,6 @@
\include{tex_de/chap9}
\include{tex_de/chap10}
\include{tex_de/chap11}
\todo{Symbolverzeichnis}
\fi
\end{document}
......@@ -21,13 +21,12 @@
\ifnum\isEng > 0
\include{tex_en/title_en}
\pagestyle{headings}
%
\include{tex_en/chap1_en}
%
\include{tex_en/chap2_en}
%\include{tex_en/chap1_en}
%\include{tex_en/chap2_en}
%\include{tex_en/chap3_en}
%\include{tex_en/chap4_en}
%\include{tex_en/chap5_en}
%
\include{tex_en/chap5_en}
%\include{tex_en/chap6_en}
%\include{tex_en/chap7_en}
%\include{tex_en/chap8_en}
......
......@@ -7,6 +7,7 @@
\bibitem{butz}\textsc{T.\@ Butz}: \textit{Fouriertransformation Für Fußgänger}. 7., aktualisierte Auflage. Wiesbaden: Vieweg+Teubner Verlag / Springer Fachmedien Wiesbaden GmbH, Wiesbaden, 2012. (\emph{tub-link}: \url{https://katalog.tub.tuhh.de/Record/669343536})
\bibitem{canny} \textsc{J.\@ Canny}, A Computational Approach To Edge Detection, \textit{IEEE Transactions on Pattern Analysis and Machine Intelligence}, 8(6):679–698, 1986.
\bibitem{FFT}\textsc{J.~W.~Cooley, J.~W.~Tukey}: An algorithm for the machine calculation of complex Fourier series. \emph{Math. Comput. 19}, (1965) 297–301.
\bibitem{georgii} \textsc{H.-O.\@ Georgii}: \textit{Stochastics: Introduction to Probability and Statistics}. 2nd rev.\@ and ext.\@ ed.\@. Berlin, De Gruyter, 2012. (\emph{tub-link}: \url{https://katalog.tub.tuhh.de/Record/745576966})
\bibitem{octave} \textsc{J.\@ W.\@ Eaton}, \textsc{D.\@ Bateman}, \textsc{S.\@ Hauberg}, \textsc{R.\@ Wehbring}: GNU Octave version 5.2.0 manual: a high-level interactive language for numerical computations, 2019. URL \url{https://www.gnu.org/software/octave/doc/v5.2.0/}
\bibitem{engelnagel}\textsc{K.-J.\@ Engel and R.\@ Nagel}: \textit{One-Parameter Semigroups for Linear Evolution Equations}. Springer Verlag, New York, Berlin, Heidelberg, 1999. (\emph{available at}: \url{https://www.math.uni-tuebingen.de/de/forschung/agfa/members/engel-nagel_one-parameter-semigroups.pdf})
\bibitem{evans}\textsc{L.\@ C.\@ Evans}: \textit{Partial Differential Equations}. 2nd ed., vol.\@ 19 of \textit{Graduate Studies in Mathematics}. American Mathematical Society, Providence, RI, 2010. (\emph{tub-link}: \url{https://katalog.tub.tuhh.de/Record/612554260})
......
% !TeX root = ../skript_live.tex
% ... sagt TeXworks, dass es ../skript_live.tex compilieren soll - nicht dieses File hier
\setcounter{chapter}{9} % eins weniger als gleich kommt
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Registration}
Image registration deals with the problem of bringing two images of the same object(s) into alignment with each other. This is typically done by finding an appropriate coordinate transformation. The exact problem is as follows:
We are given a reference image $u_0 \colon \Omega_0 \to F$ and an object image $u \colon \Omega \to F$,
......@@ -170,5 +171,3 @@
Higher order derivatives and combinations of different regularizers are also possible.
%%%% section exercises
\input{tex_en/chap10_ex}
% !TeX root = ../skript_live.tex
% ... sagt TeXworks, dass es ../skript_live.tex compilieren soll - nicht dieses File hier
\setcounter{chapter}{10} % eins weniger als gleich kommt
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Mathematical Details}\label{chap:maths}
\noindent From a mathematical viewpoint, several questions have been left unanswered, such as:
......@@ -401,5 +402,3 @@
\end{proof}
\exRef{Ex~\ref{ex:variationalCalculus}}
%%%% section exercises
\input{tex_en/chap11_ex}
\ No newline at end of file
......@@ -13,6 +13,7 @@
\item Segmentation (Detecting single objects in an image)
\item Registration (Aligning multiple images of the same object)
\end{enumerate}
\vgap{50mm}
\section{Our Focus}
\begin{enumerate}[label=\textbullet]
......
% !TeX root = ../skript_live.tex
% ... sagt TeXworks, dass es ../skript_live.tex compilieren soll - nicht dieses File hier
\setcounter{chapter}{1} % eins weniger als gleich kommt
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{What is an Image?}
\label{chap:whatImage}
%Literature Bredies Chapter 1 and 3.1
Before we formally define the notion of a (mathematical) image, we may want to ask ourselves the question: \emph{``What exactly is an image''}?
Since this question is almost philosophical, we might want to ask ourselves the following, less abstract questions instead:
\vgap{90mm} Since this question is almost philosophical, we might want to ask ourselves the following, less abstract questions instead:
\begin{itemize}
\renewcommand{\labelitemi}{$\rightarrow$}
\item What kinds of images are there?
......@@ -25,25 +28,31 @@
What all of the above examples have in common is that they result from measurements at different points, which are always discrete. This naturally leads to the notion of a \emph{discrete image}\index{Image!discrete}. Another important, albeit less intuitive, viewpoint is that of a \emph{continuous image}\index{Image!continuous}. This view is especially useful when dealing with images mathematically.
\begin{defbox}{Image, Pixel}{img}
A \emph{(continuous) image}\index{Image}\index{Image!continuous} is a mapping $u : \Omega \to F$ from the \emph{image domain}\index{Image!domain} $\Omega \subset \R^d$ to the \emph{color space}\index{Color!space} $F$. If $\Omega \subset \mathbb Z^d$, we call $u$ a \emph{discrete image}\index{Image!discrete}.
A \emph{(continuous) image}\index{Image}\index{Image!continuous} is a mapping $u : \Omega \to F$ from the \emph{image domain}\index{Image!domain} $\Omega \subset \R^d$\nomenclature{$d$}{Dimension of a vector space}\nomenclature{$\mathbb R$}{Set of real numbers} to the \emph{color space}\index{Color!space} $F$\nomenclature{$F$}{Color space}.
If $\Omega \subset \mathbb Z^d$\nomenclature{$\mathbb Z$}{Set of integers}, we call $u$ a \emph{discrete image}\index{Image!discrete}.
If $u : \Omega \to F$ is discrete, we call $i \in \Omega$ the \emph{$i$th Pixel}\index{pixel} and $u(i)$ the corresponding \emph{pixel value}\index{Pixel!value}.
\end{defbox}
\vgap{40mm}
\pbpres
\noindent As we can see, images can be of arbitrary dimension, usually denoted by $d \in \N$. Common examples are:
\begin{itemize}
\item$d=2$: 2-dimensional image
\item$d=3$: 3-dimensional image/model \underline{or} video: 2-dimensional image + time
\item$d=4$: 3-dimensional image/model + time
\end{itemize}
The color space $F$ can be any set, but we usually use $[0,1]^m$ for continuous images and $\{0,\dots,255\}^m$ for discrete images, where $m$ is the number of \emph{color channels}\index{Color!channel}. Examples:
\vgap{60mm} The color space $F$ can be any set, but we usually use $[0,1]^m$ for continuous images and $\{0,\dots,255\}^m$ for discrete images, where $m$ is the number of \emph{color channels}\index{Color!channel}. Examples:
\begin{itemize}
\item $F=[0,1]$ or $F= F_\mathrm{gr} = \{0,1,..., 255\}$: Grayscale \index{Grayscale}
\item $F=\{0,1\}$: Black/White
\item $F=[0,1]^3$ or $F=\{0,1,...,255\}^3$: RGB (Red, Green, Blue)
\index{RGB}
\end{itemize}
\vgap{60mm}
\VL{1}
\pbpres
When working with discrete images on a computer, for the image domain we will usually have
\begin{align*}
\Omega = \{ 1, \dots, N\} \times \{1, \dots, M\} = \{ (i,j) \colon i,j \in \mathbb{N}, \text{ with }1 \leq i \leq N, 1 \leq j \leq M\}
......@@ -67,7 +76,7 @@
\label{eq:rgbIm}
\Big[ A_{ij}^{(\mathrm{r})}, A_{ij}^{(\mathrm{g})}, A_{ij}^{(\mathrm{b})} \Big] \coloneqq u(i,j), \quad (i, j) \in \Omega,
\end{align}
respectively.\exRef{Ex~\ref{ex:negative}}\exRef{Ex~\ref{ex:grayscaleConversion}}
respectively.\exRef{Ex~\ref{ex:negative}}\exRef{Ex~\ref{ex:grayscaleConversion}}\exRef{Ex~\ref{ex:representation}}
Both the discrete and continuous representations have their merits. A discrete image consists of a finite amount of pixels and can therefore be stored in computer memory. This is not possible with a continuous image. On the other hand, discrete images suffer from problems when applying certain operations to them, such as scaling or rotating. This does not happen with continuous images.
......@@ -104,8 +113,9 @@
\section[Interpolation of Images]{Interpolation of Images -- Switching between Discrete and Continuous Images}\label{sect:interpolation}
\index{Interpolation}
\pap{
Depending on how we want to work with an image, we might prefer one representation over the other. Construction and analysis of methods for image processing is preferably done using the continuous representation, as it allows us to apply concepts from mathematical analysis. However, most images stem from measured data and are therefore discrete. Thus, we need a way to transform a discrete image into a continuous one, and vice-versa. The latter case is arguably the easier one:\\
}
\centerline{\textbf{Continuous $\to$ Discrete:}}
\begin{minipage}{0.4\linewidth}
......@@ -123,6 +133,7 @@
\hfill\vrule\hfill
\begin{minipage}{0.5\linewidth}
Split $\Omega$ into equally sized boxes $B_i$ with a grid. Then, assign exactly one color value to each box using either
\vwhite{30mm}{
\begin{enumerate}[label=\arabic*)]
\item the color value of the center pixel, i.e.
$u(x_i)$, where $x_i =$ midpoint of box $B_i$, or
......@@ -131,6 +142,7 @@
\displaystyle \frac{1}{\abs{B_i}} \cdot \int_{B_i}u(x)\d x.
\]
\end{enumerate}
}
\end{minipage}
Strategy 1 is simple and quick, but can be problematic. The center pixel $x_i$ may not represent $u|_{B_i}$ very well. Even further, for $u \in \Ell^p$, single point evaluation is not defined. Strategy 2 on the other hand is more complex but also more representative of $B_i$ as a whole. In fact, it is closer to the way CCD (charge-coupled device)\index{CCD} sensors in digital cameras work.
......@@ -165,10 +177,12 @@
\begin{minipage}[t]{0.55\linewidth}
\begin{enumerate}[label=\arabic*., itemsep=2cm]
\item Idea: Take the function value of the nearest midpoint, i.e. for each $x \in B_i$,
\vwhite{30mm}{
\[
u(x) \coloneqq u(x_i), \quad \text{ where } x_i = \text{midpoint of } B_i.
\]
This approach is known as \emph{nearest neighbour interpolation}\index{Interpolation!nearest neighbour} and results in each box having the same color everywhere. As a result, the image is technically (piecewise) continuous, but looks like a discrete one.
}
\end{enumerate}
\end{minipage}
......@@ -202,11 +216,14 @@
\begin{minipage}[t]{0.55\linewidth}
\begin{enumerate}[label=\arabic*., itemsep=2cm]
\setcounter{enumi}{1}
\item Idea: Let $a,b,c,d$ be the color values of the 4 surrounding midpoints. The color value at point $p \in B_i$ is then determined using a \emph{convex combination}\index{Convex!combination} (see remark below) of $a,b,c$ and $d$, such that closer values have a bigger impact on the result than ones that are further away:
\item Idea: Let $a,b,c,d$ be the color values of the 4 surrounding midpoints. The color value at point $p \in B_i$ is then determined
\vwhite{20mm}{
using a \emph{convex combination}\index{Convex!combination} (see remark below) of $a,b,c$ and $d$, such that closer values have a bigger impact on the result than ones that are further away:
\[
u(p) = (1 - \alpha)(1 - \beta)a + \alpha(1 - \beta)b + (1 - \alpha)\beta c + \alpha\beta d.
\]
This approach is known as \emph{bilinear interpolation}\index{Interpolation!bilinear}.
}
\end{enumerate}
\end{minipage}
......@@ -237,7 +254,7 @@
\index{Spline}
\begin{rembox}{Splines}{splines}
Bilinear interpolation can also interpreted as \emph{spline interpolation}\index{Spline!interpolation} with bilinear basis splines. This is treated in more detail in the exercises.
Bilinear interpolation can also be interpreted as \emph{spline interpolation}\index{Spline!interpolation} with bilinear basis splines. This is treated in more detail in the exercises.
\end{rembox}
\exRef{Ex~\ref{ex:interpolation}}
......@@ -271,7 +288,7 @@
\pa{Case 2: Discrete Image}\\
This case can be problematic since in general, $D_{-\varphi} x \not \in \Z^2$ for $x \in \Z^2$.
A way to solve this problem is to first evaluate $y = D_{-\varphi}x$ and then interpolate between the color values of the surrounding 4 pixels of $y$.
\\[-6mm]
\begin{center}
\begin{tikzpicture}
\foreach \x in {0,1,2,3}{
......@@ -300,8 +317,17 @@
\draw[decorate,decoration={brace,amplitude=4pt,mirror}] (7.9,-1.2) -- node[anchor= north] {\small $\subset \Z^d$} (10.1,-1.2);
\end{tikzpicture}
\end{center}
\exRef{Ex~\ref{ex:imageRotation}}
\exRef{Ex~\ref{ex:imageRotation}}
~\\[-20mm]
\begin{center}
\includegraphics[width=40mm]{img/line17_nn.png}
\hspace{-34mm}
{\small nearest neighbour}
\hspace{20mm}
\includegraphics[width=40mm]{img/line17_bil.png}\hspace{-15mm}
{\small bilinear}
\end{center}
\begin{thinkbox}{Something to Think About}
What happens if we take a continuous image $u$, transform it into a discrete image and then transform it back? What happens if we keep doing this? Does the answer depend on the method of transformation between the viewpoints?
......@@ -319,6 +345,3 @@
\item \cite[Section 3.1]{bredies}
\item \cite[Section 2.5, 2.6]{gonzales}
\end{itemize}
%%%%%% section with Exercises
\input{tex_en/chap2_ex}
\ No newline at end of file
......@@ -16,6 +16,7 @@
that receives an 8-bit matrix representation \texttt{A} of an image and returns the respective negative image.
If \texttt{A} is an 8-bit color image, your function should invert every channel separately.
\end{ex}
{\ifpresent\newpage\fi}
\begin{ex}[(Grayscale Conversion)]
\label{ex:grayscaleConversion}
......@@ -30,18 +31,19 @@
Implement the following methods.
Each of them should correspond to a specific value of \texttt{method}:
\noindent\texttt{method=\textquotesingle{}average\textquotesingle{}}: Each pixel of the output matrix \texttt{B} is calculated as the average of the \textrm{r}, \textrm{g}, and \textrm{b} value of the input array \texttt{A}.
\begin{enumerate}[label=(\alph*)]
\item\texttt{method=\textquotesingle{}average\textquotesingle{}}: Each pixel of the output matrix \texttt{B} is calculated as the average of the \textrm{r}, \textrm{g}, and \textrm{b} value of the input array \texttt{A}.
\noindent\texttt{method=\textquotesingle{}luma\textquotesingle{}}: Each pixel of \texttt{B} is calculated via a \emph{convex combination}\index{Convex!combination} of the form
\item \texttt{method=\textquotesingle{}luma\textquotesingle{}}: Each pixel of \texttt{B} is calculated via a \emph{convex combination}\index{Convex!combination} of the form
$$\mathrm{gray} = \mathrm{red} \cdot 0.2126 + \mathrm{green} \cdot 0.7152 + \mathrm{blue} \cdot 0.0722.$$
\noindent\texttt{method=\textquotesingle{}desaturation\textquotesingle{}}: To get a grayscale pixel value by \emph{desaturation}\index{Desaturation}, use as grayscale value the midpoint between the maximum of the (\textrm{r}, \textrm{g}, \textrm{b}) triplet and the minimum of (\textrm{r}, \textrm{g}, \textrm{b}).
\item \texttt{method=\textquotesingle{}desaturation\textquotesingle{}}: To get a grayscale pixel value by \emph{desaturation}\index{Desaturation}, use as grayscale value the midpoint between the maximum of the (\textrm{r}, \textrm{g}, \textrm{b}) triplet and the minimum of (\textrm{r}, \textrm{g}, \textrm{b}).
This formula is based on a conversion between the RGB colorspace and the HSV/HSL\index{HSV/HSL} colorspace.
\noindent\texttt{method=\textquotesingle{}digicam\textquotesingle{}}: Imitate the built-in grayscale function in some digital cameras by using as output matrix \texttt{B} the green color channel $(A_{ij}^{(\mathrm{g})})$ of your input image.
\item\texttt{method=\textquotesingle{}digicam\textquotesingle{}}: Imitate the built-in grayscale function in some digital cameras by using as output matrix \texttt{B} the green color channel $(A_{ij}^{(\mathrm{g})})$ of your input image.
\noindent\begin{minipage}{0.6\textwidth}
\texttt{method=\textquotesingle{}{4bit}\textquotesingle{}}: If this option is passed to the function, first convert the input image \texttt{A} to a grayscale representation by calling \texttt{grayscaleImg} with the argument~\texttt{method=\textquotesingle{}average\textquotesingle{}}.
\begin{minipage}{0.6\textwidth}
\item \texttt{method=\textquotesingle{}{4bit}\textquotesingle{}}: If this option is passed to the function, first convert the input image \texttt{A} to a grayscale representation by calling \texttt{grayscaleImg} with the argument~\texttt{method=\textquotesingle{}average\textquotesingle{}}.
Then, convert the resulting grayscale image to one that corresponds to a 4-bit grayscale image (only $2^4 = 16$ different shades of gray), i.e.\@ instead of values in $\{0,\dots,255\}$ the resulting image should only consist of values in
$$\{0,17,34,\dots,255\} = \{k \cdot(2^4 + 1) \colon k=0,1,\dots,15 \}.$$
This should be accomplished by mapping the current grayscale value as suggested by the plot. Note that
......@@ -77,7 +79,7 @@
\end{center}
\end{minipage}
\noindent\texttt{method=\textquotesingle{}unknown\textquotesingle{}}: In the materials for this exercise problem, you find two images \texttt{mandril\_color.png} and \texttt{mandril\_unknown.png}.
\item\texttt{method=\textquotesingle{}unknown\textquotesingle{}}: In the materials for this exercise problem, you find two images \texttt{mandril\_color.png} and \texttt{mandril\_unknown.png}.
\footnote{Link to the example images \url{https://collaborating.tuhh.de/e-10/teaching/mathematical-image-processing/lecture-notes/-/tree/master/example_img}}
Similar to \texttt{method=\textquotesingle{}luma\textquotesingle{}}, the grayscale image \texttt{mandril\_unknown.png} was constructed by using a grayscale conversion formula of the form
\begin{align}
......@@ -90,7 +92,47 @@
\textit{Hint: As there are only 3 unknowns in the \emph{linear relation} \eqref{eq:linRel}, you only need to consider 3 pixels from the original image and the corresponding pixels from the grayscale image to form a \emph{linear system of equations}.
It is even possible to use only 2 pixels...}
\end{enumerate}
\end{ex}
{\ifpresent\newpage\fi}
\begin{ex}[(Image Representation)]
\label{ex:representation}
\begin{enumerate}[label=(\alph*)]
\item You are given the image \texttt{mandril.png} below with further information from your image viewer
\begin{center}
\includegraphics[width=4cm]{./img/mandril.png}
\qquad
\includegraphics[width=4cm]{./img/mandril_properties.png}
\end{center}
Decide whether this image is discrete\index{Image!discrete} or continuous\index{Image!continuous} and specify a suitable domain\index{Image!domain} $\Omega$ and color space\index{Color!space} $F$.
\item\label{it:mat3by3} Consider the $3 \times 3$ matrix
\begin{equation*}
\begin{pmatrix}
0 & 0 & 127 \\
0 & 127 & 255 \\
127 & 255 & 255
\end{pmatrix}\;.
\end{equation*}
How would you represent this matrix as a discrete image? Specify a suitable domain $\Omega$ and color space $F$.
\item\label{it:draw3by3} For the matrix from part~\ref{it:mat3by3}, try to draw the corresponding $3 \times 3$ image on a piece of paper, making it clear where a pixel starts end ends.
\item Expand your drawing of part~\ref{it:draw3by3} by a Cartesian $(x,y)$-coordinate system.
Follow the convention that each pixel with coordinates $(i,j)$ in the above matrix, should also have the coordinates $(i,j)$ in $\mathbb{R}^2$.
Is this coordinate system\index{Coordinate system} \emph{right-handed} or \emph{left-handed}?
\item\label{it:01times01} Consider the image
\begin{equation*}
f \colon [0,1]\times [0,1] \to [0,1], \quad (x,y) \mapsto \frac{1}{2} (x^2 + y^2) \;.
\end{equation*}
Decide whether this image is discrete or continuous and specify a suitable domain\index{Image!domain} $\Omega$ and color space\index{Color!space} $F$.
\item For the image from part~\ref{it:01times01}, draw the corresponding graph
\begin{equation*}
\{ (x,y,f(x,y)) \in \mathbb{R}^3 : (x,y) \in [0,1] \times [0,1] \}\;.
\end{equation*}
\item Give an example of a \emph{continuous image} that is not given by a \emph{continuous function}\index{Function!continuous}.
\end{enumerate}
\end{ex}
{\ifpresent\newpage\fi}
\begin{ex}[(Interpolation)]
\label{ex:interpolation}
......@@ -179,6 +221,7 @@
\end{enumerate}
% Interpolation always comes with numerical errors, as we will find out during this problem.
\end{ex}
{\ifpresent\newpage\fi}
\begin{ex}[(Image Rotation)]
\label{ex:imageRotation}
......@@ -196,7 +239,8 @@
\end{pmatrix},\quad \varphi \in \mathbb{R}.
\end{align*}
\begin{enumerate}[label=(\alph*)]
\item\label{it:pad} \emph{Zero Padding}: Since our image $u$ has a finite support, i.e.\@ $|\Omega| < \infty$, it is sometimes useful for theoretical considerations to extend $u$ by zero outside of $\Omega$ which leads to the image
\item\label{it:center} \emph{Centering}: Based on $\Omega$, give a formula for calculating the center coordinates $(x_\mathrm{c}, y_\mathrm{c}) \in \mathbb{R}^2$.
\item\label{it:pad} \emph{Zero Padding}: Since our image $u$ has a finite support, i.e.\@ $|\Omega| < \infty$, it is sometimes useful for theoretical considerations to extend $u$ by zero on $\mathbb{Z}^2 \setminus \Omega$ which leads to the image
\begin{align*}
\overline{u} \colon \mathbb{Z}^2 \to F_\gr,
\quad (x,y) \mapsto
......@@ -279,4 +323,5 @@
As above, visualize the interpolation error, this time with a \texttt{\textquotesingle{}green\textquotesingle{}} line with \texttt{\textquotesingle{}*\textquotesingle{}} markers.
\end{enumerate}
\end{ex}
{\ifpresent\newpage\fi}
% !TeX root = ../skript_live.tex
% ... sagt TeXworks, dass es ../skript_live.tex compilieren soll - nicht dieses File hier
\setcounter{chapter}{2} % eins weniger als gleich kommt
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\chapter{Histograms and first Applications}
\label{chap:Histo}
%Literature: Bredies Chapter 3.2
......@@ -14,13 +15,14 @@
H_u : F \to \N_0, \\
F \ni k \mapsto \abs{\{x \in \Omega : u(x) = k\}}
\end{gather*}
is called \emph{histogram}\index{Histogram}\index{Histogram} of the image $u$.
is called \emph{histogram}\index{Histogram}\index{Histogram} of the image $u$\nomenclature{$H_u$}{Histogram of a discrete image $u$}.
\end{defbox}
$H_u(k)$ tells us how often the color value $k$ appears in $u$. Thus, there also holds
\[\sum_{k \in F}H_u(k)=\abs{\Omega}.\]
\begin{rembox}{Relative Frequency}{rel_freq}
Sometimes we are interested in the \emph{relative frequency}\index{Relative frequency} $\widetilde H_u(k) =\displaystyle \frac{H_u(k)}{\abs{\Omega}}$.
\end{rembox}
\pbpres
In the example below, we see a $2\times 2$ image $u : \{1,2\}^2 \to \{\text{black}, \text{gray}, \text{white}\}$ and its histogram~$H_u$.
......@@ -48,6 +50,7 @@
\draw (3,-0.25) node {\textbullet};
\end{tikzpicture}
\end{center}
\vgap{32mm}
When dealing with a continuous image, we require its domain $\Omega$ to be equipped with a \emph{measure}\index{Measure} $\mu$, which assigns to each measurable subset $A \subset \Omega$ a non-negative real number $\mu(A)$ that we can interpret as the size of the set.
For both discrete and continuous images $u : \Omega \to F$, the definition of the histogram $\mathcal H_u$ then generalizes to
......@@ -85,6 +88,23 @@
\section{Application: Contrast Enhancement}\index{Contrast!Enhancement}\label{sec:contrast}
Due to bad lighting conditions or wrongly adjusted optical settings, an image may exhibit \emph{low contrast}\index{Contrast!low}. An image with low contrast has gray values only in a small portion of the color space $F$ available, while a \emph{high contrast}\index{Contrast!high} image has gray values in almost all of the color space.
We can increase an image's contrast by spreading its histogram over all of $F$.
\pres{
\begin{center}
\begin{tikzpicture}
\draw[->] (0,0) node[yshift=-4, xshift = -4] {$0$} -- (4.2,0) node[right] {$F$};
\draw[->] (0,0) -- (0,2);
\draw[thick] plot [smooth, tension = 0.8] coordinates {(1.5,0) (1.75,0.75) (2,0.5) (2.25,1.25) (2.5,0)};
\tvmark{1.5}{0}{$k_{\min}$}
\tvmark{2.5}{0}{$k_{\max}$}
\draw[->,thick] (4.25,1) -- (4.75,1);
\draw[->] (5,0) node[yshift=-4, xshift = -4] {$0$} -- (9.2,0) node[right] {$F$};
\draw[->] (5,0) -- (5,2);
\draw[thick,shift={(5,0)}] plot [smooth, tension = 0.8] coordinates {(0,0) (1,0.75) (2,0.5) (3,1.25) (4,0)};
\tvmark{9}{0}{$N$}
\end{tikzpicture}
\end{center}
}
\vgap{5mm}
Our general approach is to define a transformation $\varphi : F \to F$, which is then composed with the image $u$:\\
......@@ -108,6 +128,8 @@
\end{align*}
\end{minipage}}
\vspace{\parskip}
\vgap{10mm}
\pa{1. Approach: Contrast Stretching}\index{Contrast!Stretching}\index{Histogram!Stretching}
......@@ -138,7 +160,7 @@
\begin{align}
\varphi(k) = \frac{k - k_{\min}}{k_{\max} - k_{\min}} N.
\end{align}
If the color space is discrete, the value $\varphi(k)$ needs to be rounded to the nearest color value, i.e.
If the color space $F$ is discrete, the value $\varphi(k)$ needs to be rounded to the nearest element of $F$, say
\begin{align}
\varphi(k) = \left[\frac{k - k_{\min}}{k_{\max} - k_{\min}} N \right].
\end{align}
......@@ -177,7 +199,7 @@
Even after the histogram has been stretched out, the contrast might still be improvable. Another way to do this is presented in the second approach.