This commit is contained in:
Nguyễn Anh Khoa
2019-05-14 22:37:19 +07:00
commit a43837539e
250 changed files with 26352 additions and 0 deletions

View File

@ -0,0 +1,924 @@
\documentclass[english,11pt,table,handout]{beamer}
\input{dsa-style.tex}
\usepackage{pgf}
\newcommand{\Rule}[2]{\genfrac{}{}{0.7pt}{}{{\setlength{\fboxrule}{0pt}\setlength{\fboxsep}{3mm}\fbox{$#1$}}}{{\setlength{\fboxrule}{0pt}\setlength{\fboxsep}{3mm}\fbox{$#2$}}}}
\newcommand{\Rulee}[3]{\genfrac{}{}{0.7pt}{}{{\setlength{\fboxrule}{0pt}\setlength{\fboxsep}{3mm}\fbox{$#1$}}}{{\setlength{\fboxrule}{0pt}\setlength{\fboxsep}{3mm}\fbox{$#2$}}}[#3]}
\usepackage{url}
\usepackage{qtree}
\usepackage{datetime}
\usepackage{amsfonts}
\usepackage{mathtools}
\usepackage{fancybox}
\usepackage[linesnumbered]{algorithm2e}
\usepackage{ragged2e}
\lecture[3]{Local Processing on Images}{lecture-text}
% \subtitle{Sequence Control}
\date{09 September 2015}
\newcounter{saveenumi}
\usepackage{wrapfig}
\usetikzlibrary{automata,arrows,positioning, chains, shapes.callouts, calc}
\tikzstyle{mnode}=[circle, draw, fill=black, inner sep=0pt, minimum width=4pt]
\tikzstyle{thinking} = [draw=blue, very thick]
\edef\sizetape{1cm}
\tikzstyle{tmtape}=[draw,minimum size=\sizetape]
\tikzstyle{tmhead}=[arrow box,draw,minimum size=.5cm,arrow box
arrows={east:.25cm, west:0.25cm}]
\tikzset{
level/.style = { ultra thick, blue },
connect/.style = { dashed, red },
notice/.style = { draw, rectangle callout, callout relative pointer={#1} },
label/.style = { text width=4cm }
}
\begin{document}
\begin{frame}
\selectlanguage{english}
\maketitle
\end{frame}
\begin{frame}\frametitle<presentation>{Overview}
\tableofcontents
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Local processing}
\frame
{
\Huge
\begin{center}
\textcolor{blue}{\textbf{What is local processing?}}
\end{center}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\frame
{
\frametitle{What is local processing?}
\selectlanguage{english}
\begin{block}{Definition}
Local processing is an image operation where each pixel value $I(u, v)$ is changed by a \textbf{function} of the intensities of pixels in a neighborhood of the pixel $(u, v)$.
\end{block}
\begin{figure}[!h]
\includegraphics[scale=0.5]{localproc.png}
\end{figure}
}
\frame
{
\frametitle{What is local processing?}
\begin{block}{Example of neighborhood}
\begin{itemize}
\item An image $I(u,v)$; a pixel $(u,v)$ and its neighborhood of $3\times 3 $ pixels
\end{itemize}
\end{block}
\centering
\begin{figure}[!h]
\includegraphics[scale=0.5]{neighborhood.png}
\end{figure}
}
\frame
{
\frametitle{What is local processing?}
\begin{example}{Examples of some processing functions}
\begin{itemize}
\item Linear functions
\begin{enumerate}
\item Averaging function
\item Shifting function
\item Gaussian function
\item Edge detecting function
\end{enumerate}
\item Non-linear functions
\begin{enumerate}
\item Median function
\item Min function
\item Max function
\end{enumerate}
\end{itemize}
\end{example}
}
\frame
{
\frametitle{What is local processing?}
\begin{itemize}
\item Example of an averaging function
\end{itemize}
\centering
\begin{figure}[!h]
\includegraphics[scale=0.5]{neighborhood.png}
\end{figure}
\begin{equation*}
I^{'}{(u,v)} = \frac{1}{9}\sum_{i=-1}^{1}{\sum_{j=-1}^{1}{I(u+i, v+j)}}
\end{equation*}
}
\frame
{
\frametitle{What is local processing?}
\begin{itemize}
\item Example of an averaging function
\end{itemize}
\centering
\begin{figure}[!h]
\begin{tabular}{cc}
\includegraphics[scale=0.11]{kyoto_gray.jpg} &
\includegraphics[scale=0.11]{kyoto_gray_smooth_9.jpg} \\
Input image & Output image
\end{tabular}
\end{figure}
\begin{itemize}
\item The output image is obtained by averaging the input with neighborhood of $9 \times 9$ pixels.
\end{itemize}
}
\frame
{
\frametitle{What is local processing?}
\begin{itemize}
\item Example of an averaging function
\end{itemize}
\centering
\begin{figure}[!h]
\begin{tabular}{cc}
\includegraphics[scale=0.11]{kyoto_gray.jpg} &
\includegraphics[scale=0.11]{kyoto_gray_smooth_9.jpg} \\
Input image & Output image \\
& blurred, smoothed
\end{tabular}
\end{figure}
\begin{equation*}
I^{'}{(u,v)} = \frac{1}{9\times 9}\sum_{i=-4}^{4}{\sum_{4=-4}^{4}{I(u+i, v+j)}}
\end{equation*}
}
\frame
{
\frametitle{What is local processing?}
\begin{itemize}
\item Example of a median function (a non-linear function)
\end{itemize}
\centering
\begin{figure}[!h]
\begin{tabular}{cc}
\includegraphics[scale=0.57]{image_salt_peper.png} &
\includegraphics[scale=0.57]{image_salt_peper_denoise.png} \\
Input image & Output image\\
& Noises have been removed
\end{tabular}
\end{figure}
\begin{itemize}
\item The output image is obtained by computing the median value of a set of pixels in a neighborhood of $5 \times 5$ pixels.
\end{itemize}
}
\section{Linear processing}
\frame
{
\Huge
\begin{center}
\textcolor{blue}{\textbf{Linear processing function}}
\end{center}
}
\subsection{Correlation}
\frame
{
\frametitle{Mean function}
Consider an averaging function on square window. In general, the window can have different size of each dimension. The output of the averaging is determined by.
\begin{equation*}
\begin{split}
I^{'}{(u,v)} &= \frac{1}{(2r+1) \times (2r+1)} \sum_{i=-r}^{r}{\sum_{-r}^{r}{I(u+i, v+j)}}
\end{split}
\end{equation*}
$I^{'}(u,v)$ can be written as
\begin{equation*}
\begin{split}
I^{'}{(u,v)} &= \sum_{i=-r}^{r}{\sum_{-r}^{r}{I(u+i, v+j).H_{corr}{(i,j)}}}
\end{split}
\end{equation*}
}
\frame
{
\frametitle{Mean function}
\begin{enumerate}
\item $H_{corr}$ is a matrix of size $(2r+1) \times (2r+1)$
\item $H_{corr} = \frac{1}{(2r+1) \times (2r+1)} M_{identity}$
and,
\item $M_{identity}$ : is an identity matrix of size $(2r+1) \times (2r+1)$
\end{enumerate}
\begin{example}
Matrix for averaging pixels in a neighborhood of size $5 \times 5$, i.e., $r= 2$.
$$
H_{corr} = \frac{1}{5 \times 5} \times
\begin{bmatrix}
1 & 1 & 1 & 1 & 1 \\
1 & 1 & 1 & 1 & 1 \\
1 & 1 & 1 & 1 & 1 \\
1 & 1 & 1 & 1 & 1 \\
1 & 1 & 1 & 1 & 1 \\
\end{bmatrix}
$$
\end{example}
}
\frame
{
\frametitle{From averaging function to others}
\begin{block}{A way to construct other linear processing functions}
If one changes $H_{corr}$ to other kinds of matrix, he obtains other linear function.
\end{block}
\begin{example}
Edge detecting function (Sobel)
$$
H_{corr} =
\begin{bmatrix}
1 & 0 & -1 \\
2 & 0 & -2 \\
1 & 0 & -1 \\
\end{bmatrix}
\quad
H_{corr} =
\begin{bmatrix}
1 & 2 & 1 \\
0 & 0 & 0 \\
-1 & -2 & -1 \\
\end{bmatrix}
$$
Shifting function
$$
H_{corr} =
\begin{bmatrix}
0 & 0 & 0 \\
0 & 0 & 1 \\
0 & 0 & 0 \\
\end{bmatrix}
$$
\end{example}
}
\frame
{
\frametitle{Correlation}
\begin{block}{Definition}
Input data:
\begin{enumerate}
\item Input image, $I(u,v)$
\item Matrix $H_{corr}{(i,j)}$ of size $(2r+1) \times (2r+1)$. In general, the size on two dimensions maybe different.
\end{enumerate}
\textbf{Correlation} is defined as follows:
\begin{equation*}
\begin{split}
I_{corr}^{'}{(u,v)} &= \sum_{i=-r}^{r}{\sum_{-r}^{r}{I(u+i, v+j).H_{corr}{(i,j)}}}
\end{split}
\end{equation*}
\end{block}
}
\frame
{
\frametitle{Correlation: How does it works?}
\selectlanguage{english}
\begin{figure}[!h]
\includegraphics[scale=0.57]{correlation.png}
\caption{Method for computing the correlation for one pixel}
\end{figure}
}
\frame
{
\frametitle{Correlation: How does it works?}
\selectlanguage{english}
\begin{block}{A computation process}
For each pixel $(u,v)$ on the output image, do:
\begin{enumerate}
\item \textbf{Place} matrix $H_{corr}$ centered at the corresponding pixel, i.e., pixel $(u,v)$, on the input image
\item \textbf{Multiply} coefficients in matrix $H_{corr}$ with the underlying pixels on the input image.
\item \textbf{Compute} the sum of all the resulting products in the previous step.
\item \textbf{Assign} the sum to the $I^{'}(u,v)$.
\end{enumerate}
\end{block}
}
\subsection{Convolution}
\frame
{
\frametitle{Convolution}
\selectlanguage{english}
\begin{block}{Definition}
Input data:
\begin{enumerate}
\item Input image, $I(u,v)$
\item Matrix $H_{conv}$ of size $(2r+1) \times (2r+1)$. In general, the size on two dimensions maybe different.
\end{enumerate}
\textbf{Convolution} is defined as follows:
\begin{equation*}
\begin{split}
I_{conv}^{'}{(u,v)} &= \sum_{i=-r}^{r}{\sum_{-r}^{r}{I(u-i, v-j).H_{conv}{(i,j)}}}
\end{split}
\end{equation*}
\end{block}
}
\frame
{
\frametitle{Convolution}
\selectlanguage{english}
\begin{block}{Natation}
\begin{itemize}
\item \alert{Operator *} is used to denote the convolution between image $I$ and matrix $H_{conv}$
\item That is
\begin{equation*}
\begin{split}
I_{conv}^{'}{(u,v)} &= I * H_{conv} \\
&= \sum_{i=-r}^{r}{\sum_{-r}^{r}{I(u-i, v-j).H_{conv}{(i,j)}}}
\end{split}
\end{equation*}
\end{itemize}
\end{block}
}
\frame
{
\frametitle{Convolution}
\selectlanguage{english}
\begin{alertblock}{Attention!}
\begin{itemize}
\item When $I$ is an gray image, both of $I$ and $H_{conv}$ are matrices.
\item However, $I * H_{conv}$ is convolution between $I$ and $H_{conv}$, \textbf{instead of matrix multiplication}!
\end{itemize}
\end{alertblock}
}
\frame
{
\frametitle{Convolution and Correlation}
\selectlanguage{english}
\begin{block}{Mathematics}
\begin{equation*}
\begin{split}
I_{conv}^{'}{(u,v)} &= \sum_{i=-r}^{r}{\sum_{-r}^{r}{I(u-i, v-j).H_{conv}{(i,j)}}} \\
I_{corr}^{'}{(u,v)} &= \sum_{i=-r}^{r}{\sum_{-r}^{r}{I(u+i, v+j).H_{corr}{(i,j)}}}
\end{split}
\end{equation*}
\end{block}
In mathematics, convolution and correlation are different in the \textbf{sign} of $i$ and $j$ inside of $I(u+i, v+j)$ and $I(u-i, v-j)$
}
\frame
{
\frametitle{Convolution and Correlation}
\selectlanguage{english}
\begin{block}{Convolution to Correlation}
\begin{itemize}
\item Let $s=-i$ and $t=-j$
\item We have
\end{itemize}
\begin{equation*}
\begin{split}
I_{conv}^{'}{(u,v)} &= \sum_{i=-r}^{r}{\sum_{-r}^{r}{I(u-i, v-j).H_{conv}{(i,j)}}} \\
&= \sum_{i=-r}^{r}{\sum_{-r}^{r}{I(u+s, v+t).H_{conv}{(-s,-t)}}}
\end{split}
\end{equation*}
\end{block}
\begin{alertblock}{$H_{conv}{(-s,-t)}$ from $H_{conv}{(i,j)}$}
$H_{conv}{(-s,-t)}$ can be obtained from $H_{conv}{(i,j)}$ by either
\begin{itemize}
\item \textbf{Flipping} $H_{conv}{(i,j)}$ on x and then on y axis
\item \textbf{Rotating} $H_{conv}{(i,j)}$ around its center $180^0$
\end{itemize}
\end{alertblock}
}
\frame
{
\frametitle{Convolution and Correlation}
\selectlanguage{english}
\begin{example}
Demonstration of rotation and flipping.
$$
H =
\begin{bmatrix}
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9 \\
\end{bmatrix}
\quad
H_{flipped\_x} =
\begin{bmatrix}
3 & 2 & 1 \\
6 & 5 & 4 \\
9 & 8 & 7 \\
\end{bmatrix}
$$
$H_{flipped\_x}$ is obtained from $H$ by flipping $H$ on x-axis.
After flipping $H_{flipped\_x}$ around y axis
$$
H_{flipped_xy} =
\begin{bmatrix}
9 & 8 & 7 \\
6 & 5 & 4 \\
3 & 2 & 1 \\
\end{bmatrix}
$$
$H_{flipped\_xy}$ can obtained from $H$ by rotating $H$ $180^0$ around $H$'s center.
\end{example}
}
\frame
{
\frametitle{Convolution and Correlation}
\selectlanguage{english}
\begin{block}{Correlation to Convolution}
\begin{itemize}
\item Let $s=-i$ and $t=-j$
\item We have
\end{itemize}
\begin{equation*}
\begin{split}
I_{corr}^{'}{(u,v)} &= \sum_{i=-r}^{r}{\sum_{-r}^{r}{I(u+i, v+j).H_{corr}{(i,j)}}} \\
&= \sum_{i=-r}^{r}{\sum_{-r}^{r}{I(u-s, v-t).H_{corr}{(-s,-t)}}}
\end{split}
\end{equation*}
\end{block}
\begin{alertblock}{$H_{corr}{(-s,-t)}$ from $H_{corr}{(i,j)}$}
$H_{corr}{(-s,-t)}$ can be obtained from $H_{corr}{(i,j)}$ by either
\begin{itemize}
\item \textbf{Flipping} $H_{corr}{(i,j)}$ on x and then on y axis
\item \textbf{Rotating} $H_{corr}{(i,j)}$ around its center $180^0$
\end{itemize}
\end{alertblock}
}
\frame
{
\frametitle{Convolution-Correlation Conversion}
\selectlanguage{english}
\begin{alertblock}{Relationship}
\begin{enumerate}
\item Convolution can be computed by correlation and vice versa.
\item For example, convolution can be computed by correlation by: first, \alert{(a)} rotating the matrix $180^0$ and then \alert{(b)} computing the correlation between the rotated matrix with the input image.
\end{enumerate}
\end{alertblock}
}
\frame
{
\frametitle{Convolution: How does it works?}
\selectlanguage{english}
\begin{block}{A Computation process}
\begin{enumerate}
\item \textbf{Rotate} matrix $H_{conv}$ around its center $180^0$ to obtain $H_{corr}$
\end{enumerate}
For each pixel $(u,v)$ on the output image, do:
\begin{enumerate}
\item \textbf{Place} matrix $H_{corr}$ centered at the corresponding pixel, i.e., pixel $(u,v)$, on the input image
\item \textbf{Multiply} coefficients in matrix $H_{corr}$ with the underlying pixels on the input image.
\item \textbf{Compute} the sum of all the resulting products in the previous step.
\item \textbf{Assign} the sum to the $I^{'}(u,v)$.
\end{enumerate}
\end{block}
}
\frame
{
\frametitle{MATLAB's function}
\selectlanguage{english}
\begin{example}
MATLAB's functions supports correlation and convolution
\begin{enumerate}
\item \alert{\textbf{corr2}}
\item \alert{\textbf{xcorr2}}
\item \alert{\textbf{conv2}}
\item \alert{\textbf{filter2}}
\item \alert{\textbf{imfilter}}
\end{enumerate}
MATLAB's function supports creating special matrix
\begin{enumerate}
\item \alert{\textbf{fspecial}}
\end{enumerate}
\end{example}
}
\subsection{Linear Filtering}
\frame
{
\frametitle{Linear Filtering}
\selectlanguage{english}
\begin{block}{Definition}
Linear filtering is a process of applying the \alert{\textbf{convolution}} between an matrix $H$ to input image $I(u,v)$.
\end{block}
\begin{block}{Model of a filter system}
\begin{figure}[!h]
\includegraphics[scale=0.57]{filtersys.png}
\caption{Filter image $I(u,v)$ with matrix $H$ to obtain $I^{'}(u,v)$}
\end{figure}
\centering
$I^{'}(u,v) = I(u,v)*H(i,j)$
\end{block}
}
\frame
{
\frametitle{Filter's kernel}
\selectlanguage{english}
\begin{block}{Definition}
In filtering, matrix $H$ is called the filter's kernel.
\end{block}
\begin{block}{Other names of $H$}
\begin{itemize}
\item Filter's kernel
\item Window
\item Mask
\item Template
\item Matrix
\item Local region
\end{itemize}
\end{block}
}
\subsection{Popular Linear Filter}
\frame
{
\frametitle{Popular Linear Filter: Mean filter}
\selectlanguage{english}
\begin{example}
Mean filter's kernel
\begin{itemize}
\item General case:
\end{itemize}
$$
H_{corr} = \frac{1}{(2r+1)^2} \times
\begin{bmatrix}
1 & 1 & ... & 1 & 1 \\
1 & 1 & ... & 1 & 1 \\
... & ... & ... & ... & ... \\
1 & 1 & ... & 1 & 1 \\
1 & 1 & ... & 1 & 1 \\
\end{bmatrix}_{(2r+1) \times (2r+1)}
$$
\end{example}
}
\frame
{
\frametitle{Popular Linear Filter: Mean filter}
\selectlanguage{english}
\begin{figure}
\begin{tabular}{cc}
\includegraphics[scale=0.53]{char.png} &
\includegraphics[scale=0.53]{char_mean_3_3.png} \\
Original image & Filtered with $H$'s size: $3 \times 3$
\end{tabular}
\end{figure}
}
\frame
{
\frametitle{Popular Linear Filter: Mean filter}
\selectlanguage{english}
\begin{figure}
\begin{tabular}{cc}
\includegraphics[scale=0.53]{char_mean_5_5.png} &
\includegraphics[scale=0.53]{char_mean_11_11.png} \\
Filtered with $H$'s size: $5 \times 5$ & Filtered with $H$'s size: $11 \times 11$
\end{tabular}
\end{figure}
}
\frame
{
\frametitle{Popular Linear Filter: Gaussian filter}
\selectlanguage{english}
\begin{block}{2D-Gaussian Function}
\begin{equation*}
\begin{split}
G(x,y, \sigma) &= \frac{1}{2\pi{\sigma}^2} exp({-\frac{x^2 + y^2}{{2\sigma}^2}})
\end{split}
\end{equation*}
\end{block}
\begin{figure}
\includegraphics[scale=0.3]{gaussian.png}
\caption{2D-Gaussian Function}
\end{figure}
}
\frame
{
\frametitle{Popular Linear Filter: Gaussian filter}
\selectlanguage{english}
\begin{example}
\begin{itemize}
\item $H$'s size is $3 \times 3$
\item $\sigma = 0.5$
\end{itemize}
$$
H =
\begin{bmatrix}
0.0113 & 0.0838 & 0.0113\\
0.0838 & 0.6193 & 0.0838\\
0.0113 & 0.0838 & 0.0113
\end{bmatrix}
$$
\begin{itemize}
\item $H$'s size is $5 \times 5$
\item $\sigma = 0.5$
\end{itemize}
$$
H =
\begin{bmatrix}
0.0000 & 0.0000 & 0.0002 & 0.0000 & 0.0000\\
0.0000 & 0.0113 & 0.0837 & 0.0113 & 0.0000\\
0.0002 & 0.0837 & 0.6187 & 0.0837 & 0.0002\\
0.0000 & 0.0113 & 0.0837 & 0.0113 & 0.0000\\
0.0000 & 0.0000 & 0.0002 & 0.0000 & 0.0000
\end{bmatrix}
$$
\end{example}
}
\frame
{
\frametitle{Popular Linear Filter: Gaussian filter}
\selectlanguage{english}
\begin{figure}
\begin{tabular}{cc}
\includegraphics[scale=0.53]{char_mean_11_11.png} &
\includegraphics[scale=0.53]{char_gaussian_11_11_05.png} \\
Filtered with Mean filter & Filtered with Gaussian filter \\
$H$'s size: $11 \times 11$ & $H$'s size: $11 \times 11$ \\
& $\sigma =0.5$
\end{tabular}
\end{figure}
}
\frame
{
\frametitle{Popular Linear Filter: Shifting filter}
\selectlanguage{english}
\begin{example}
\begin{itemize}
\item In order to shift pixel $(u,v)$ to $(u-2, v+2)$, use the following kernel
\end{itemize}
$$
H =
\begin{bmatrix}
0 & 0 & 0 & 0 & 1\\
0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0\\
\end{bmatrix}
$$
\end{example}
}
\frame
{
\frametitle{Popular Linear Filter: Shifting filter}
\selectlanguage{english}
\begin{figure}
\begin{tabular}{cc}
\includegraphics[scale=0.53]{char.png} &
\includegraphics[scale=0.53]{char_shifted_2_2.png} \\
Original image & Shifted with $d=[-2, 2]$
\end{tabular}
\end{figure}
}
\subsection{Convolution's Analysis}
\frame
{
\frametitle{Convolution's Complexity}
\selectlanguage{english}
\begin{block}{Computational Complexity}
\begin{itemize}
\item Input image $I$ has size $N \times M$
\item Kernel's size is $(2r+1) \times (2r+1)$
\item Then, the computational complexity is as follows:
\end{itemize}
\begin{equation*}
\begin{split}
O(MN(2r+1)(2r+1)) &= O(MNr^2)
\end{split}
\end{equation*}
\end{block}
}
\frame
{
\frametitle{Convolution's Properties}
\selectlanguage{english}
\begin{block}{Commutativity:}
\centering
$I * H = H * I$
\end{block}
\begin{alertblock}{Meaning}
\begin{enumerate}
\item This means that we can think of the image as the kernel and the kernel as the image and get the same result.
\item In other words, we can leave the image fixed and slide the kernel or leave the kernel fixed and slide the image.
\end{enumerate}
\end{alertblock}
}
\frame
{
\frametitle{Convolution's Properties}
\selectlanguage{english}
\begin{block}{Associativity:}
\centering
$(I * H_{1})*H_{2} =I * (H_{1}*H_{2})$
\end{block}
\begin{alertblock}{Meaning}
\begin{enumerate}
\item This means that we can apply $H_{1}$ to $I$ followed by $H_{2}$, or we can convolve the kernel $H_{2} * H_{1}$ and then apply the resulting kernel to $I$.
\end{enumerate}
\end{alertblock}
}
\frame
{
\frametitle{Convolution's Properties}
\selectlanguage{english}
\begin{block}{Linearity:}
\centering
$(\alpha .I)* H = \alpha. (I * H)$
$(I_{1} + I_{2}) * H = I_{1} * H + I_{2}*H$
\end{block}
\begin{alertblock}{Meaning}
\begin{enumerate}
\item This means that we can multiply an image by a constant before or after convolution, and we can add two images before or after convolution and get the same results.
\end{enumerate}
\end{alertblock}
}
\frame
{
\frametitle{Convolution's Properties}
\selectlanguage{english}
\begin{block}{Shift-Invariance}
Let $S$ be an operator that shifts an image I:
\centering
$S(I)(u,v) = I(u+a, v+b)$
\flushleft Then,
\centering
$S(I*H) = S(I)*H$
\end{block}
\begin{alertblock}{Meaning}
\begin{enumerate}
\item This means that we can convolve $I$ and $H$ and then shift the result, or we can shift $I$ and then convolve it with $H$.
\end{enumerate}
\end{alertblock}
}
\frame
{
\frametitle{Convolution's Properties}
\selectlanguage{english}
\begin{block}{Separability}
A kernel H is called separable if it can be broken down into the convolution of two kernels:
\centering $H = H_{1} * H_{2}$
\flushleft More generally, we might have:
\centering $H = H_{1} * H_{2}* ... * H_{n}$
\end{block}
}
\frame
{
\frametitle{Convolution's Properties}
\selectlanguage{english}
\begin{block}{Saving the computation with separability}
If we can separate a kernel H into two smaller kernels $H = H_{1} * H_{2}$, then it will often be cheaper to apply $H_{1}$ followed by $H_{2}$, rather than $H$.
\end{block}
Because, we have
\begin{block}{Associativity:}
\centering
$(I * H_{1})*H_{2} =I * (H_{1}*H_{2})$
\end{block}
}
\frame
{
\frametitle{Convolution's Properties}
\selectlanguage{english}
\begin{example}
$$
H_{x} =
\begin{bmatrix}
1 & 1 & 1 & 1 & 1
\end{bmatrix}
\quad
H_{y} =
\begin{bmatrix}
1 \\ 1 \\ 1
\end{bmatrix}
$$
Then,
$$
H_{x} = H_{x} * H_{y} =
\begin{bmatrix}
1 & 1 & 1 & 1 & 1\\
1 & 1 & 1 & 1 & 1\\
1 & 1 & 1 & 1 & 1
\end{bmatrix}
$$
\end{example}
}
\frame
{
\frametitle{Processing at the boundary of image}
\selectlanguage{english}
\begin{figure}[!h]
\includegraphics[scale=0.57]{boundary_effect.png}
\caption{Without any special consideration, the processing is invalid at boundary pixels}
\end{figure}
}
\frame
{
\frametitle{Processing at the boundary of image}
\selectlanguage{english}
\begin{block}{Methods for processing boundary pixels}
\begin{enumerate}
\item \textbf{Cropping}:do not process boundary pixels. Just obtain a smaller output image by cropping the output image.
\item \textbf{Padding}: pad a band of pixels (with zeros) to the boundary of input image. Perform the processing and the crop to get the output image.
\item \textbf{Extending}: copy pixels on the boundary to outside to get a new image. Perform the processing and the crop to get the output image.
\item \textbf{Wrapping}: reflect pixels on the boundary to outside to get a new image. Perform the processing and the crop to get the output image.
\end{enumerate}
\end{block}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

View File

@ -0,0 +1,236 @@
% Copyright 2007 by Till Tantau
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Public License.
%
% See the file doc/licenses/LICENSE for more details.
% Common packages
\usepackage[utf8x]{inputenc}
\usepackage[vietnam,english]{babel}
\usepackage[utf8]{vietnam}
%\usepackage{times}
\usefonttheme[onlymath]{serif}
\usecolortheme{default}
\usepackage{booktabs}
\usepackage{mathpartir}
\usepackage{listings}
\usepackage{listingsutf8}
\usepackage{pbox}
\mprset{flushleft}
\mode<article>
{
\usepackage{times}
\usepackage{mathptmx}
\usepackage[left=1.5cm,right=6cm,top=1.5cm,bottom=3cm]{geometry}
}
\usepackage{hyperref}
\usepackage{tikz}
\usetikzlibrary{arrows,backgrounds}
%\tikzstyle{mnode}=[circle, draw, fill=black, inner sep=0pt, minimum width=4pt]
\usepackage{colortbl}
%\usepackage{yfonts}
\usepackage{translator} % comment this, if not available
% Common settings for all lectures in this course
\def\lecturename{Image Processing and Computer Vision}
\title{\insertlecture}
\author{\textbf{LE Thanh Sach}}
\institute
{
\textit{Faculty of Computer Science and Engineering}\\
\textit{Ho Chi Minh University of Technology, VNU-HCM}
}
\subject{Lecturer \lecturename}
% Beamer version theme settings
\useoutertheme[height=0pt,width=2cm,right]{sidebar}
\usecolortheme{rose,sidebartab}
\useinnertheme{circles}
\usefonttheme[only large]{structurebold}
\setbeamercolor{sidebar right}{bg=black!15}
\setbeamercolor{structure}{fg=blue}
\setbeamercolor{author}{parent=structure}
\setbeamerfont{title}{series=\normalfont,size=\LARGE}
\setbeamerfont{title in sidebar}{series=\bfseries}
\setbeamerfont{author in sidebar}{series=\bfseries}
\setbeamerfont*{item}{series=}
\setbeamerfont{frametitle}{size=}
\setbeamerfont{block title}{size=\small}
\setbeamerfont{subtitle}{size=\normalsize,series=\normalfont}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{bibliography item}[book]
\setbeamertemplate{sidebar right}
{
{\usebeamerfont{title in sidebar}%
\vskip1.5em%
\hskip3pt%
\usebeamercolor[fg]{title in sidebar}%
\insertshorttitle[width=2cm,center,respectlinebreaks]\par%
\vskip1.25em%
}%
{%
\hskip3pt%
\usebeamercolor[fg]{author in sidebar}%
\usebeamerfont{author in sidebar}%
\insertshortauthor[width=2cm,center,respectlinebreaks]\par%
\vskip1.25em%
}%
\hbox to2cm{\hss\insertlogo\hss}
\vskip1.25em%
\insertverticalnavigation{2cm}%
\vfill
\hbox to 2cm{\hfill\usebeamerfont{subsection in
sidebar}\strut\usebeamercolor[fg]{subsection in
sidebar}\insertshortlecture.\insertframenumber\hskip5pt}%
\vskip3pt%
}%
\setbeamertemplate{title page}
{
\vbox{}
\vskip1em
{\huge Chapter \insertshortlecture\par}
{\usebeamercolor[fg]{title}\usebeamerfont{title}\inserttitle\par}%
\ifx\insertsubtitle\@empty%
\else%
\vskip0.25em%
{\usebeamerfont{subtitle}\usebeamercolor[fg]{subtitle}\insertsubtitle\par}%
\fi%
\vskip1em\par
\emph{\lecturename}\
%on \insertdate\par
\vskip3em\par
\leftskip=0pt plus1fill\insertauthor\par
\insertinstitute\vskip1em
}
\logo{\includegraphics[width=1.5cm]{hcmut.png}}
% Article version layout settings
\mode<article>
\makeatletter
\def\@listI{\leftmargin\leftmargini
\parsep 0pt
\topsep 5\p@ \@plus3\p@ \@minus5\p@
\itemsep0pt}
\let\@listi=\@listI
\setbeamertemplate{frametitle}{\paragraph*{\insertframetitle\
\ \small\insertframesubtitle}\ \par
}
\setbeamertemplate{frame end}{%
\marginpar{\scriptsize\hbox to 1cm{\sffamily%
\hfill\strut\insertshortlecture.\insertframenumber}\hrule height .2pt}}
\setlength{\marginparwidth}{1cm}
\setlength{\marginparsep}{4.5cm}
\def\@maketitle{\makechapter}
\def\makechapter{
\newpage
\null
\vskip 2em%
{%
\parindent=0pt
\raggedright
\sffamily
\vskip8pt
{\fontsize{36pt}{36pt}\selectfont Chapter \insertshortlecture \par\vskip2pt}
{\fontsize{24pt}{28pt}\selectfont \color{blue!50!black} \insertlecture\par\vskip4pt}
{\Large\selectfont \color{blue!50!black} \insertsubtitle\par}
\vskip10pt
\normalsize\selectfont Print version of
Lecturer \emph{\lecturename} of \@date\par\vskip1.5em
%\hfill Le Thanh Sach and Luong The Nhan, Faculty of CSE, HCMC University of Technology
}
\par
\vskip 1.5em%
}
\let\origstartsection=\@startsection
\def\@startsection#1#2#3#4#5#6{%
\origstartsection{#1}{#2}{#3}{#4}{#5}{#6\normalfont\sffamily\color{blue!50!black}\selectfont}}
\makeatother
\mode
<all>
% Typesetting Listings
\usepackage{listings}
\lstset{language=Java}
\alt<presentation>
{\lstset{%
basicstyle=\footnotesize\ttfamily,
commentstyle=\slshape\color{green!50!black},
keywordstyle=\bfseries\color{blue!50!black},
identifierstyle=\color{blue},
stringstyle=\color{orange},
escapechar=\#,
emphstyle=\color{red}}
}
{
\lstset{%
basicstyle=\ttfamily,
keywordstyle=\bfseries,
commentstyle=\itshape,
escapechar=\#,
emphstyle=\bfseries\color{red}
}
}
% Common theorem-like environments
\theoremstyle{example}
\newtheorem{exercise}[theorem]{\translate{Exercise}}
% New useful definitions:
\newbox\mytempbox
\newdimen\mytempdimen
\newcommand\includegraphicscopyright[3][]{%
\leavevmode\vbox{\vskip3pt\raggedright\setbox\mytempbox=\hbox{\includegraphics[#1]{#2}}%
\mytempdimen=\wd\mytempbox\box\mytempbox\par\vskip1pt%
\fontsize{3}{3.5}\selectfont{\color{black!25}{\vbox{\hsize=\mytempdimen#3}}}\vskip3pt%
}}
\newenvironment{colortabular}[1]{\medskip\rowcolors[]{1}{blue!20}{blue!10}\tabular{#1}\rowcolor{blue!40}}{\endtabular\medskip}
\def\equad{\leavevmode\hbox{}\quad}
\newenvironment{greencolortabular}[1]
{\medskip\rowcolors[]{1}{green!50!black!20}{green!50!black!10}%
\tabular{#1}\rowcolor{green!50!black!40}}%
{\endtabular\medskip}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 231 KiB

View File

@ -0,0 +1,446 @@
% Mathpartir --- Math Paragraph for Typesetting Inference Rules
%
% Copyright (C) 2001, 2002, 2003, 2004, 2005 Didier R<>my
%
% Author : Didier Remy
% Version : 1.2.0
% Bug Reports : to author
% Web Site : http://pauillac.inria.fr/~remy/latex/
%
% Mathpartir is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2, or (at your option)
% any later version.
%
% Mathpartir is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details
% (http://pauillac.inria.fr/~remy/license/GPL).
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% File mathpartir.sty (LaTeX macros)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mathpartir}
[2005/12/20 version 1.2.0 Math Paragraph for Typesetting Inference Rules]
%%
%% Identification
%% Preliminary declarations
\RequirePackage {keyval}
%% Options
%% More declarations
%% PART I: Typesetting maths in paragraphe mode
%% \newdimen \mpr@tmpdim
%% Dimens are a precious ressource. Uses seems to be local.
\let \mpr@tmpdim \@tempdima
% To ensure hevea \hva compatibility, \hva should expands to nothing
% in mathpar or in inferrule
\let \mpr@hva \empty
%% normal paragraph parametters, should rather be taken dynamically
\def \mpr@savepar {%
\edef \MathparNormalpar
{\noexpand \lineskiplimit \the\lineskiplimit
\noexpand \lineskip \the\lineskip}%
}
\def \mpr@rulelineskip {\lineskiplimit=0.3em\lineskip=0.2em plus 0.1em}
\def \mpr@lesslineskip {\lineskiplimit=0.6em\lineskip=0.5em plus 0.2em}
\def \mpr@lineskip {\lineskiplimit=1.2em\lineskip=1.2em plus 0.2em}
\let \MathparLineskip \mpr@lineskip
\def \mpr@paroptions {\MathparLineskip}
\let \mpr@prebindings \relax
\newskip \mpr@andskip \mpr@andskip 2em plus 0.5fil minus 0.5em
\def \mpr@goodbreakand
{\hskip -\mpr@andskip \penalty -1000\hskip \mpr@andskip}
\def \mpr@and {\hskip \mpr@andskip}
\def \mpr@andcr {\penalty 50\mpr@and}
\def \mpr@cr {\penalty -10000\mpr@and}
\def \mpr@eqno #1{\mpr@andcr #1\hskip 0em plus -1fil \penalty 10}
\def \mpr@bindings {%
\let \and \mpr@andcr
\let \par \mpr@andcr
\let \\\mpr@cr
\let \eqno \mpr@eqno
\let \hva \mpr@hva
}
\let \MathparBindings \mpr@bindings
% \@ifundefined {ignorespacesafterend}
% {\def \ignorespacesafterend {\aftergroup \ignorespaces}
\newenvironment{mathpar}[1][]
{$$\mpr@savepar \parskip 0em \hsize \linewidth \centering
\vbox \bgroup \mpr@prebindings \mpr@paroptions #1\ifmmode $\else
\noindent $\displaystyle\fi
\MathparBindings}
{\unskip \ifmmode $\fi\egroup $$\ignorespacesafterend}
\newenvironment{mathparpagebreakable}[1][]
{\begingroup
\par
\mpr@savepar \parskip 0em \hsize \linewidth \centering
\mpr@prebindings \mpr@paroptions #1%
\vskip \abovedisplayskip \vskip -\lineskip%
\ifmmode \else $\displaystyle\fi
\MathparBindings
}
{\unskip
\ifmmode $\fi \par\endgroup
\vskip \belowdisplayskip
\noindent
\ignorespacesafterend}
% \def \math@mathpar #1{\setbox0 \hbox {$\displaystyle #1$}\ifnum
% \wd0 < \hsize $$\box0$$\else \bmathpar #1\emathpar \fi}
%%% HOV BOXES
\def \mathvbox@ #1{\hbox \bgroup \mpr@normallineskip
\vbox \bgroup \tabskip 0em \let \\ \cr
\halign \bgroup \hfil $##$\hfil\cr #1\crcr \egroup \egroup
\egroup}
\def \mathhvbox@ #1{\setbox0 \hbox {\let \\\qquad $#1$}\ifnum \wd0 < \hsize
\box0\else \mathvbox {#1}\fi}
%% Part II -- operations on lists
\newtoks \mpr@lista
\newtoks \mpr@listb
\long \def\mpr@cons #1\mpr@to#2{\mpr@lista {\\{#1}}\mpr@listb \expandafter
{#2}\edef #2{\the \mpr@lista \the \mpr@listb}}
\long \def\mpr@snoc #1\mpr@to#2{\mpr@lista {\\{#1}}\mpr@listb \expandafter
{#2}\edef #2{\the \mpr@listb\the\mpr@lista}}
\long \def \mpr@concat#1=#2\mpr@to#3{\mpr@lista \expandafter {#2}\mpr@listb
\expandafter {#3}\edef #1{\the \mpr@listb\the\mpr@lista}}
\def \mpr@head #1\mpr@to #2{\expandafter \mpr@head@ #1\mpr@head@ #1#2}
\long \def \mpr@head@ #1#2\mpr@head@ #3#4{\def #4{#1}\def#3{#2}}
\def \mpr@flatten #1\mpr@to #2{\expandafter \mpr@flatten@ #1\mpr@flatten@ #1#2}
\long \def \mpr@flatten@ \\#1\\#2\mpr@flatten@ #3#4{\def #4{#1}\def #3{\\#2}}
\def \mpr@makelist #1\mpr@to #2{\def \mpr@all {#1}%
\mpr@lista {\\}\mpr@listb \expandafter {\mpr@all}\edef \mpr@all {\the
\mpr@lista \the \mpr@listb \the \mpr@lista}\let #2\empty
\def \mpr@stripof ##1##2\mpr@stripend{\def \mpr@stripped{##2}}\loop
\mpr@flatten \mpr@all \mpr@to \mpr@one
\expandafter \mpr@snoc \mpr@one \mpr@to #2\expandafter \mpr@stripof
\mpr@all \mpr@stripend
\ifx \mpr@stripped \empty \let \mpr@isempty 0\else \let \mpr@isempty 1\fi
\ifx 1\mpr@isempty
\repeat
}
\def \mpr@rev #1\mpr@to #2{\let \mpr@tmp \empty
\def \\##1{\mpr@cons ##1\mpr@to \mpr@tmp}#1\let #2\mpr@tmp}
%% Part III -- Type inference rules
\newif \if@premisse
\newbox \mpr@hlist
\newbox \mpr@vlist
\newif \ifmpr@center \mpr@centertrue
\def \mpr@htovlist {%
\setbox \mpr@hlist
\hbox {\strut
\ifmpr@center \hskip -0.5\wd\mpr@hlist\fi
\unhbox \mpr@hlist}%
\setbox \mpr@vlist
\vbox {\if@premisse \box \mpr@hlist \unvbox \mpr@vlist
\else \unvbox \mpr@vlist \box \mpr@hlist
\fi}%
}
% OLD version
% \def \mpr@htovlist {%
% \setbox \mpr@hlist
% \hbox {\strut \hskip -0.5\wd\mpr@hlist \unhbox \mpr@hlist}%
% \setbox \mpr@vlist
% \vbox {\if@premisse \box \mpr@hlist \unvbox \mpr@vlist
% \else \unvbox \mpr@vlist \box \mpr@hlist
% \fi}%
% }
\def \mpr@item #1{$\displaystyle #1$}
\def \mpr@sep{2em}
\def \mpr@blank { }
\def \mpr@hovbox #1#2{\hbox
\bgroup
\ifx #1T\@premissetrue
\else \ifx #1B\@premissefalse
\else
\PackageError{mathpartir}
{Premisse orientation should either be T or B}
{Fatal error in Package}%
\fi \fi
\def \@test {#2}\ifx \@test \mpr@blank\else
\setbox \mpr@hlist \hbox {}%
\setbox \mpr@vlist \vbox {}%
\if@premisse \let \snoc \mpr@cons \else \let \snoc \mpr@snoc \fi
\let \@hvlist \empty \let \@rev \empty
\mpr@tmpdim 0em
\expandafter \mpr@makelist #2\mpr@to \mpr@flat
\if@premisse \mpr@rev \mpr@flat \mpr@to \@rev \else \let \@rev \mpr@flat \fi
\def \\##1{%
\def \@test {##1}\ifx \@test \empty
\mpr@htovlist
\mpr@tmpdim 0em %%% last bug fix not extensively checked
\else
\setbox0 \hbox{\mpr@item {##1}}\relax
\advance \mpr@tmpdim by \wd0
%\mpr@tmpdim 1.02\mpr@tmpdim
\ifnum \mpr@tmpdim < \hsize
\ifnum \wd\mpr@hlist > 0
\if@premisse
\setbox \mpr@hlist
\hbox {\unhbox0 \hskip \mpr@sep \unhbox \mpr@hlist}%
\else
\setbox \mpr@hlist
\hbox {\unhbox \mpr@hlist \hskip \mpr@sep \unhbox0}%
\fi
\else
\setbox \mpr@hlist \hbox {\unhbox0}%
\fi
\else
\ifnum \wd \mpr@hlist > 0
\mpr@htovlist
\mpr@tmpdim \wd0
\fi
\setbox \mpr@hlist \hbox {\unhbox0}%
\fi
\advance \mpr@tmpdim by \mpr@sep
\fi
}%
\@rev
\mpr@htovlist
\ifmpr@center \hskip \wd\mpr@vlist\fi \box \mpr@vlist
\fi
\egroup
}
%%% INFERENCE RULES
\@ifundefined{@@over}{%
\let\@@over\over % fallback if amsmath is not loaded
\let\@@overwithdelims\overwithdelims
\let\@@atop\atop \let\@@atopwithdelims\atopwithdelims
\let\@@above\above \let\@@abovewithdelims\abovewithdelims
}{}
%% The default
\def \mpr@@fraction #1#2{\hbox {\advance \hsize by -0.5em
$\displaystyle {#1\mpr@over #2}$}}
\def \mpr@@nofraction #1#2{\hbox {\advance \hsize by -0.5em
$\displaystyle {#1\@@atop #2}$}}
\let \mpr@fraction \mpr@@fraction
%% A generic solution to arrow
\def \mpr@make@fraction #1#2#3#4#5{\hbox {%
\def \mpr@tail{#1}%
\def \mpr@body{#2}%
\def \mpr@head{#3}%
\setbox1=\hbox{$#4$}\setbox2=\hbox{$#5$}%
\setbox3=\hbox{$\mkern -3mu\mpr@body\mkern -3mu$}%
\setbox3=\hbox{$\mkern -3mu \mpr@body\mkern -3mu$}%
\dimen0=\dp1\advance\dimen0 by \ht3\relax\dp1\dimen0\relax
\dimen0=\ht2\advance\dimen0 by \dp3\relax\ht2\dimen0\relax
\setbox0=\hbox {$\box1 \@@atop \box2$}%
\dimen0=\wd0\box0
\box0 \hskip -\dimen0\relax
\hbox to \dimen0 {$%
\mathrel{\mpr@tail}\joinrel
\xleaders\hbox{\copy3}\hfil\joinrel\mathrel{\mpr@head}%
$}}}
%% Old stuff should be removed in next version
\def \mpr@@nothing #1#2
{$\lower 0.01pt \mpr@@nofraction {#1}{#2}$}
\def \mpr@@reduce #1#2{\hbox
{$\lower 0.01pt \mpr@@fraction {#1}{#2}\mkern -15mu\rightarrow$}}
\def \mpr@@rewrite #1#2#3{\hbox
{$\lower 0.01pt \mpr@@fraction {#2}{#3}\mkern -8mu#1$}}
\def \mpr@infercenter #1{\vcenter {\mpr@hovbox{T}{#1}}}
\def \mpr@empty {}
\def \mpr@inferrule
{\bgroup
\ifnum \linewidth<\hsize \hsize \linewidth\fi
\mpr@rulelineskip
\let \and \qquad
\let \hva \mpr@hva
\let \@rulename \mpr@empty
\let \@rule@options \mpr@empty
\let \mpr@over \@@over
\mpr@inferrule@}
\newcommand {\mpr@inferrule@}[3][]
{\everymath={\displaystyle}%
\def \@test {#2}\ifx \empty \@test
\setbox0 \hbox {$\vcenter {\mpr@hovbox{B}{#3}}$}%
\else
\def \@test {#3}\ifx \empty \@test
\setbox0 \hbox {$\vcenter {\mpr@hovbox{T}{#2}}$}%
\else
\setbox0 \mpr@fraction {\mpr@hovbox{T}{#2}}{\mpr@hovbox{B}{#3}}%
\fi \fi
\def \@test {#1}\ifx \@test\empty \box0
\else \vbox
%%% Suggestion de Francois pour les etiquettes longues
%%% {\hbox to \wd0 {\RefTirName {#1}\hfil}\box0}\fi
{\hbox {\RefTirName {#1}}\box0}\fi
\egroup}
\def \mpr@vdotfil #1{\vbox to #1{\leaders \hbox{$\cdot$} \vfil}}
% They are two forms
% \inferrule [label]{[premisses}{conclusions}
% or
% \inferrule* [options]{[premisses}{conclusions}
%
% Premisses and conclusions are lists of elements separated by \\
% Each \\ produces a break, attempting horizontal breaks if possible,
% and vertical breaks if needed.
%
% An empty element obtained by \\\\ produces a vertical break in all cases.
%
% The former rule is aligned on the fraction bar.
% The optional label appears on top of the rule
% The second form to be used in a derivation tree is aligned on the last
% line of its conclusion
%
% The second form can be parameterized, using the key=val interface. The
% folloiwng keys are recognized:
%
% width set the width of the rule to val
% narrower set the width of the rule to val\hsize
% before execute val at the beginning/left
% lab put a label [Val] on top of the rule
% lskip add negative skip on the right
% left put a left label [Val]
% Left put a left label [Val], ignoring its width
% right put a right label [Val]
% Right put a right label [Val], ignoring its width
% leftskip skip negative space on the left-hand side
% rightskip skip negative space on the right-hand side
% vdots lift the rule by val and fill vertical space with dots
% after execute val at the end/right
%
% Note that most options must come in this order to avoid strange
% typesetting (in particular leftskip must preceed left and Left and
% rightskip must follow Right or right; vdots must come last
% or be only followed by rightskip.
%
%% Keys that make sence in all kinds of rules
\def \mprset #1{\setkeys{mprset}{#1}}
\define@key {mprset}{andskip}[]{\mpr@andskip=#1}
\define@key {mprset}{lineskip}[]{\lineskip=#1}
\define@key {mprset}{flushleft}[]{\mpr@centerfalse}
\define@key {mprset}{center}[]{\mpr@centertrue}
\define@key {mprset}{rewrite}[]{\let \mpr@fraction \mpr@@rewrite}
\define@key {mprset}{atop}[]{\let \mpr@fraction \mpr@@nofraction}
\define@key {mprset}{myfraction}[]{\let \mpr@fraction #1}
\define@key {mprset}{fraction}[]{\def \mpr@fraction {\mpr@make@fraction #1}}
\define@key {mprset}{sep}{\def\mpr@sep{#1}}
\newbox \mpr@right
\define@key {mpr}{flushleft}[]{\mpr@centerfalse}
\define@key {mpr}{center}[]{\mpr@centertrue}
\define@key {mpr}{rewrite}[]{\let \mpr@fraction \mpr@@rewrite}
\define@key {mpr}{myfraction}[]{\let \mpr@fraction #1}
\define@key {mpr}{fraction}[]{\def \mpr@fraction {\mpr@make@fraction #1}}
\define@key {mpr}{left}{\setbox0 \hbox {$\TirName {#1}\;$}\relax
\advance \hsize by -\wd0\box0}
\define@key {mpr}{width}{\hsize #1}
\define@key {mpr}{sep}{\def\mpr@sep{#1}}
\define@key {mpr}{before}{#1}
\define@key {mpr}{lab}{\let \RefTirName \TirName \def \mpr@rulename {#1}}
\define@key {mpr}{Lab}{\let \RefTirName \TirName \def \mpr@rulename {#1}}
\define@key {mpr}{narrower}{\hsize #1\hsize}
\define@key {mpr}{leftskip}{\hskip -#1}
\define@key {mpr}{reduce}[]{\let \mpr@fraction \mpr@@reduce}
\define@key {mpr}{rightskip}
{\setbox \mpr@right \hbox {\unhbox \mpr@right \hskip -#1}}
\define@key {mpr}{LEFT}{\setbox0 \hbox {$#1$}\relax
\advance \hsize by -\wd0\box0}
\define@key {mpr}{left}{\setbox0 \hbox {$\TirName {#1}\;$}\relax
\advance \hsize by -\wd0\box0}
\define@key {mpr}{Left}{\llap{$\TirName {#1}\;$}}
\define@key {mpr}{right}
{\setbox0 \hbox {$\;\TirName {#1}$}\relax \advance \hsize by -\wd0
\setbox \mpr@right \hbox {\unhbox \mpr@right \unhbox0}}
\define@key {mpr}{RIGHT}
{\setbox0 \hbox {$#1$}\relax \advance \hsize by -\wd0
\setbox \mpr@right \hbox {\unhbox \mpr@right \unhbox0}}
\define@key {mpr}{Right}
{\setbox \mpr@right \hbox {\unhbox \mpr@right \rlap {$\;\TirName {#1}$}}}
\define@key {mpr}{vdots}{\def \mpr@vdots {\@@atop \mpr@vdotfil{#1}}}
\define@key {mpr}{after}{\edef \mpr@after {\mpr@after #1}}
\newcommand \mpr@inferstar@ [3][]{\setbox0
\hbox {\let \mpr@rulename \mpr@empty \let \mpr@vdots \relax
\setbox \mpr@right \hbox{}%
$\setkeys{mpr}{#1}%
\ifx \mpr@rulename \mpr@empty \mpr@inferrule {#2}{#3}\else
\mpr@inferrule [{\mpr@rulename}]{#2}{#3}\fi
\box \mpr@right \mpr@vdots$}
\setbox1 \hbox {\strut}
\@tempdima \dp0 \advance \@tempdima by -\dp1
\raise \@tempdima \box0}
\def \mpr@infer {\@ifnextchar *{\mpr@inferstar}{\mpr@inferrule}}
\newcommand \mpr@err@skipargs[3][]{}
\def \mpr@inferstar*{\ifmmode
\let \@do \mpr@inferstar@
\else
\let \@do \mpr@err@skipargs
\PackageError {mathpartir}
{\string\inferrule* can only be used in math mode}{}%
\fi \@do}
%%% Exports
% Envirnonment mathpar
\let \inferrule \mpr@infer
% make a short name \infer is not already defined
\@ifundefined {infer}{\let \infer \mpr@infer}{}
\def \TirNameStyle #1{\small \textsc{#1}}
\def \tir@name #1{\hbox {\small \TirNameStyle{#1}}}
\let \TirName \tir@name
\let \DefTirName \TirName
\let \RefTirName \TirName
%%% Other Exports
% \let \listcons \mpr@cons
% \let \listsnoc \mpr@snoc
% \let \listhead \mpr@head
% \let \listmake \mpr@makelist
\endinput

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,166 @@
%%
%% This is file `mhsetup.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% mhsetup.dtx (with options: `package')
%%
%% It may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%% http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2003/12/01 or later.
%%
%% This work has the LPPL maintenance status "maintained".
%%
%% The Current Maintainer of this work is Morten H\o gholm.
%%
%% This work consists of the files mhsetup.dtx and mhsetup.ins and
%% the derived file mhsetup.sty.
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mhsetup}
[2004/10/10 v1.0b programming setup (MH)]
\def\MHInternalSyntaxOn{
\edef\MHInternalSyntaxOff{%
\catcode`\noexpand\~=\the\catcode`\~\relax
\catcode`\noexpand\ =\the\catcode`\ \relax
\catcode`\noexpand\^^I=\the\catcode`\^^I\relax
\catcode`\noexpand\@=\the\catcode`\@\relax
\catcode`\noexpand\:=\the\catcode`\:\relax
\catcode`\noexpand\_=\the\catcode`\_\relax
\endlinechar=\the\endlinechar\relax
}%
\catcode`\~=10\relax
\catcode`\ =9\relax
\catcode`\^^I=9\relax
\makeatletter
\catcode`\_=11\relax
\catcode`\:=11\relax
\endlinechar=` %
\relax
}
\MHInternalSyntaxOn
\AtEndOfPackage{\MHInternalSyntaxOff}
\let\MH_let:NwN \let
\def\MH_let:cN #1#2{
\expandafter\MH_let:NwN \csname#1\endcsname#2}
\def\MH_let:cc #1#2{
\expandafter\MH_let:NwN\csname#1\expandafter\endcsname
\csname#2\endcsname}
\def\MH_new_boolean:n #1{
\expandafter\@ifdefinable\csname if_boolean_#1:\endcsname{
\@namedef{boolean_#1_true:}
{\MH_let:cN{if_boolean_#1:}\iftrue}
\@namedef{boolean_#1_false:}
{\MH_let:cN{if_boolean_#1:}\iffalse}
\@nameuse{boolean_#1_false:}%
}
}
\def\MH_set_boolean_F:n #1{ \@nameuse{boolean_#1_false:} }
\def\MH_set_boolean_T:n #1{ \@nameuse{boolean_#1_true:} }
\def\MH_if_boolean:nTF #1{
\@nameuse{if_boolean_#1:}
\expandafter\@firstoftwo
\else:
\expandafter\@secondoftwo
\fi:
}
\def\MH_if_boolean:nT #1{
\@nameuse{if_boolean_#1:}
\expandafter\@firstofone
\else:
\expandafter\@gobble
\fi:
}
\def\MH_if_boolean:nF #1{
\@nameuse{if_boolean_#1:}
\expandafter\@gobble
\else:
\expandafter\@firstofone
\fi:
}
\@ifundefined{if:w}{\MH_let:NwN \if:w =\if}{}
\@ifundefined{if_meaning:NN}{\MH_let:NwN \if_meaning:NN =\ifx}{}
\@ifundefined{else:}{\MH_let:NwN \else:=\else}{}
\@ifundefined{fi:}{\MH_let:NwN \fi:=\fi}{}
\@ifundefined{if_num:w}{\MH_let:NwN \if_num:w =\ifnum}{}
\@ifundefined{if_dim:w}{\MH_let:NwN \if_dim:w =\ifdim}{}
\@ifundefined{if_case:w}{\MH_let:NwN \if_case:w =\ifcase}{}
\@ifundefined{or:}{\MH_let:NwN \or:=\or}{}
\def\MH_cs_to_str:N {\expandafter\@gobble\string}
\@ifundefined{eTeXversion}
{
\MH_let:NwN \MH_protected:\relax
\def\MH_setlength:dn{\setlength}
\def\MH_addtolength:dn{\addtolength}
}
{
\MH_let:NwN \MH_protected:\protected
\def\MH_setlength:dn #1#2{#1=\dimexpr#2\relax\relax}
\def\MH_addtolength:dn #1#2{\advance#1 \dimexpr#2\relax\relax}
}
\def\MH_keyval_alias_with_addon:nnnn #1#2#3#4{
\@namedef{KV@#1@#2}{\@nameuse{KV@#1@#3}#4}
\@namedef{KV@#1@#2@default}{\@nameuse{KV@#1@#3@default}#4}}
\def\MH_keyval_alias:nnn #1#2#3{
\MH_keyval_alias_with_addon:nnnn {#1}{#2}{#3}{}}
\def\MH_use_choice_i:nnnn #1#2#3#4{#1}
\def\MH_use_choice_ii:nnnn #1#2#3#4{#2}
\def\MH_use_choice_iii:nnnn #1#2#3#4{#3}
\def\MH_use_choice_iv:nnnn #1#2#3#4{#4}
\long\def\MH_nospace_ifnextchar:Nnn #1#2#3{
\MH_let:NwN\reserved@d=~#1
\def\reserved@a{#2}
\def\reserved@b{#3}
\futurelet\@let@token\MH_nospace_nextchar:
}
\def\MH_nospace_nextchar:{
\if_meaning:NN \@let@token\reserved@d
\MH_let:NwN \reserved@b\reserved@a
\fi:
\reserved@b
}
\long\def\MH_nospace_testopt:nn #1#2{
\MH_nospace_ifnextchar:Nnn[
{#1}
{#1[{#2}]}
}
\def\MH_nospace_protected_testopt:n #1{
\if_meaning:NN \protect\@typeset@protect
\expandafter\MH_nospace_testopt:nn
\else:
\@x@protect#1
\fi:
}
\@ifundefined{kernel@ifnextchar}
{\MH_let:NwN \kernel@ifnextchar \@ifnextchar}
{}
\MH_let:NwN \MH_kernel_xargdef:nwwn \@xargdef
\long\def\MH_nospace_xargdef:nwwn #1[#2][#3]#4{
\@ifdefinable#1{
\expandafter\def\expandafter#1\expandafter{
\expandafter
\MH_nospace_protected_testopt:n
\expandafter
#1
\csname\string#1\endcsname
{#3}}
\expandafter\@yargdef
\csname\string#1\endcsname
\tw@
{#2}
{#4}}}
\providecommand*\MHPrecedingSpacesOff{
\MH_let:NwN \@xargdef \MH_nospace_xargdef:nwwn
}
\providecommand*\MHPrecedingSpacesOn{
\MH_let:NwN \@xargdef \MH_kernel_xargdef:nwwn
}
\endinput
%%
%% End of file `mhsetup.sty'.

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB