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,964 @@
\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}
\usepackage{verbatim}
\lecture[3]{Image Derivatives}{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}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\frame
%{
% \Huge
% \begin{center}
% \textcolor{blue}{\textbf{What is local processing?}}
% \end{center}
%}
\section{Image model}
\frame
{
\frametitle{Image Model}
\selectlanguage{english}
\begin{block}{Image model}
\begin{itemize}
\item Image is a function of two variables $x$ and $y$: $f(x,y)$
\item It can seen as a surface on 2D-space.
\end{itemize}
\end{block}
\begin{figure}[!h]
\begin{tabular}{cc}
\includegraphics[scale=0.5]{char.png} &
\includegraphics[scale=0.25]{char_mesh.png} \\
An gray image & Mesh model of the image
\end{tabular}
\end{figure}
}
\section{First-order derivative}
\frame
{
\frametitle{Derivative of one variable function}
\selectlanguage{english}
Taylor expansion for $f(x + \Delta x)$:
\begin{align}
\label{taylor_right}
f(x + \Delta x) &= f(x) + \Delta x \times f^{'}(x) +\frac{{\Delta x}^2}{2!} \times f^{''}(x) + O({\Delta x}^3)
\end{align}
\begin{block}{First-order derivative from Eq. (\ref{taylor_right})}
\alert{\textbf{Forward Approximation:}}
\begin{equation*}
\begin{split}
f^{'}(x) &\cong \frac{f(x+ \Delta x) - f(x)}{\Delta x}\\
&\cong f(x+1) - f(x) \quad \text{\alert{\textbf{in discrete domain}}}
\end{split}
\end{equation*}
\begin{itemize}
\item This approximation has error $O({\Delta x})$
\end{itemize}
\end{block}
}
\frame
{
\frametitle{Derivative of one variable function}
\selectlanguage{english}
Taylor expansion for $f(x - \Delta x)$:
\begin{align}
\label{taylor_left}
f(x - \Delta x) &= f(x) - \Delta x \times f^{'}(x) +\frac{{\Delta x}^2}{2!} \times f^{''}(x) - O({\Delta x}^3)
\end{align}
\begin{block}{First-order derivative from Eq. (\ref{taylor_left})}
\alert{\textbf{Backward Approximation:}}
\begin{equation*}
\begin{split}
f^{'}(x) &\cong \frac{f(x) - f(x- \Delta x)}{\Delta x}\\
&\cong f(x) - f(x-1) \quad \text{\alert{\textbf{in discrete domain}}}
\end{split}
\end{equation*}
\begin{itemize}
\item This approximation has error $O({\Delta x})$
\end{itemize}
\end{block}
}
\frame
{
\frametitle{Derivative of one variable function}
\selectlanguage{english}
Eq. (\ref{taylor_right}) - Eq. (\ref{taylor_left})
\begin{align}
\nonumber
f(x + \Delta x) &= f(x) + \Delta x \times f^{'}(x) +\frac{{\Delta x}^2}{2!} \times f^{''}(x) + O({\Delta x}^3) \\
\nonumber
f(x - \Delta x) &= f(x) - \Delta x \times f^{'}(x) +\frac{{\Delta x}^2}{2!} \times f^{''}(x) - O({\Delta x}^3)
\end{align}
\begin{block}{First-order derivative from Eq. (\ref{taylor_right}) - Eq. (\ref{taylor_left}) }
\alert{\textbf{Central Approximation:}}
\begin{align}
\nonumber
f^{'}(x) &\cong \frac{f(x+ \Delta) - f(x- \Delta x)}{2\Delta x} &&\\
\nonumber
&\cong \frac{f(x+1) - f(x-1)}{2} &\text{\alert{\textbf{in discrete domain}}} \\
\nonumber
&\cong f(x+1) - f(x-1) &\text{\alert{\textbf{in discrete domain}}}
\end{align}
\begin{itemize}
\item This approximation has error $O({\Delta x}^2)$
\end{itemize}
\end{block}
}
\frame
{
\frametitle{Derivative of one variable function}
\selectlanguage{english}
\begin{alertblock}{Notation}
\begin{align}
\nonumber
f_x &\equiv \frac{\partial f(x,y)}{\partial x}\\
\nonumber
& \\
\nonumber
f_y &\equiv \frac{\partial f(x,y)}{\partial y}
\end{align}
\end{alertblock}
}
\frame
{
\frametitle{First-Order derivative of image}
\selectlanguage{english}
\renewcommand{\arraystretch}{3}
\begin{tabular}{|*2{>{\renewcommand{\arraystretch}{1}}l|}}
\hline
\textbf{Derivatives} & \textbf{Kernel of filters}\\
\hline
$f_x \cong f(x+1, y) - f(x,y)$ &
$H_{x} = $ $\left[ \begin{array}{cc} 1 & -1 \end{array}\right]$\\
\hline
$f_x \cong f(x, y) - f(x-1,y)$ &
$H_{x} = $ $ \left[ \begin{array}{cc} 1 & -1 \end{array}\right]$\\
\hline
$f_x \cong f(x+1, y) - f(x-1,y)$ &
$H_{x} =$ $ \left[ \begin{array}{ccc} 1 & 0 & -1 \end{array}\right]$\\
\hline
\end{tabular}
}
\frame
{
\frametitle{First-Order derivative of image}
\selectlanguage{english}
In general, fist-order derivatives can be computed by linear filters with the following kernels
\newline
\centering
\begin{tabular}{|l||l|}
\hline
Derivative on x & Derivative on y \\
\hline
& \\
$H_{x} = \left[ \begin{array}{cc} 1 & -1 \end{array}\right]^T$ &
$H_{y} = \left[ \begin{array}{cc} 1 & -1 \end{array}\right]^T$\\
&\\
\hline
& \\
$H_{x} = \left[ \begin{array}{cc} -1 & 1 \end{array}\right]^T$ &
$H_{y} = \left[ \begin{array}{cc} -1 & 1 \end{array}\right]^T$\\
&\\
\hline
& \\
$H_{x} = \left[ \begin{array}{ccc} -1 & 0 & 1 \end{array}\right]^T$ &
$H_{y} = \left[ \begin{array}{ccc} -1 & 0 & 1 \end{array}\right]^T$\\
&\\
\hline
& \\
$H_{x} = \left[ \begin{array}{ccc} 1 & 0 & -1 \end{array}\right]^T$ &
$H_{y} = \left[ \begin{array}{ccc} 1 & 0 & -1 \end{array}\right]^T$\\
&\\
\hline
\end{tabular}
}
\frame
{
\frametitle{First-Order derivative of image}
\selectlanguage{english}
Other kernels for computing first-order derivatives
\renewcommand{\arraystretch}{1}
\centering
\begin{tabular}{|*3{>{\renewcommand{\arraystretch}{2}}l|}}
\hline
\textbf{Name} & \textbf{Derivative on x} & \textbf{Derivative on y}\\
\hline
\textbf{Prewitt} &
$H_{x} = $ $\left[ \begin{array}{rrr}
-1 & 0 & 1 \\
-1 & 0 & 1 \\
-1 & 0 & 1 \\
\end{array}\right]$ &
$H_{y} = $ $\left[ \begin{array}{rrr}
-1 & -1 & -1 \\
0 & 0 & 0 \\
1 & 1 & 1 \\
\end{array}\right]$\\
\hline
\textbf{Sobel} &
$H_{x} = $ $\left[ \begin{array}{rrr}
-1 & 0 & 1 \\
-2 & 0 & 2 \\
-1 & 0 & 1 \\
\end{array}\right]$ &
$H_{y} = $ $\left[ \begin{array}{rrr}
-1 & -2 & -1 \\
0 & 0 & 0 \\
1 & 2 & 1 \\
\end{array}\right]$\\
\hline
\textbf{Robert} &
$H_{x} = $ $\left[ \begin{array}{rr}
-1 & 0\\
0 & 1 \\
\end{array}\right]$ &
$H_{y} = $ $\left[ \begin{array}{rr}
0 & -1\\
1 & 0 \\
\end{array}\right]$\\
\hline
\end{tabular}
}
\frame
{
\frametitle{First-Order derivative of image}
\selectlanguage{english}
\begin{alertblock}{Properties}
\begin{enumerate}
\item First-order derivatives are operators that can be used to obtain the \alert{\textbf{variation of intensities}} on x and y axis.
\item First-order derivatives can be either \alert{\textbf{positive}} or \alert{\textbf{negative}}.
\item A large variation of intensities $\equiv$ \alert{\textbf{strong edge}} $\equiv$ large value in the absolute of derivatives.
\item In order to display derivatives, we need to scale derivative images.
\end{enumerate}
\end{alertblock}
}
\begin{frame}[fragile]
\frametitle{First-Order derivative of image}
\selectlanguage{english}
\begin{example}
\lstset{language=Matlab}
\begin{lstlisting}
clear; close all; clc;
im = checkerboard(50, 5, 5);
im = uint8(255*(im > 0.5));
H_1st_x = [1 0 -1];
H_1st_y = [1 0 -1]';
im_1st_x = abs(imfilter(double(im), H_1st_x));
im_1st_y = abs(imfilter(double(im), H_1st_y));
figure, imshow(im), title('Input Image');
figure, imshow(gscale(im_1st_x)),
title('1st derivative on x');
figure, imshow(gscale(im_1st_y)),
title('1st derivative on y');
\end{lstlisting}
\end{example}
\end{frame}
\begin{frame}[fragile]
\frametitle{First-Order derivative of image}
\selectlanguage{english}
\begin{exercise}
\begin{figure}[!h]
\includegraphics[scale=0.35]{checkboard.png}
\caption{a chessboard shown by \alert{imshow(gscale(im))}}
\end{figure}
\begin{itemize}
\item What is the image obtained from the filtering with derivatives kernels?
\end{itemize}
\end{exercise}
\end{frame}
\begin{frame}[fragile]
\frametitle{First-Order derivative of image}
\selectlanguage{english}
\begin{itemize}
\item Sobel and Prewitt kernel can be obtained by function \alert{\textbf{fspecial}} in Matab
\item In Matlab, the input image should be casted to \alert{\textbf{float}} or \alert{\textbf{double}} before filtering with function \alert{\textbf{imfilter}}
\end{itemize}
\begin{example}
\lstset{language=Matlab}
\begin{lstlisting}
clear; close all; clc;
im = imread('cameraman.tif');
H_1st_x = fspecial('Sobel');
H_1st_y = fspecial('Sobel')'; %' = transpose
im_1st_x = abs(imfilter(double(im), H_1st_x));
im_1st_y = abs(imfilter(double(im), H_1st_y));
figure, imshow(im), title('Input Image');
figure, imshow(gscale(im_1st_x)),
title('1st derivative on x');
figure, imshow(gscale(im_1st_y)),
title('1st derivative on y');
\end{lstlisting}
\end{example}
\end{frame}
\section{Gradient}
\frame
{
\frametitle{Gradient}
\selectlanguage{english}
\begin{alertblock}{Definition}
Gradient at a pixel in a image $f(x,y)$ is a vector $\nabla f$. It is defined as
\centering
$\nabla f = $
$\left[ \begin{array}{r}
f_x \\
f_y
\end{array}\right]$
\end{alertblock}
}
\frame
{
\frametitle{Gradient}
\selectlanguage{english}
\begin{block}{Magnitude and angle of gradient vectors}
\textbf{Magnitude} of gradient is computed by:
$|\nabla f|= \sqrt{f_{x}^{2} + f_{y}^{2}}$
or, approximated by
$|\nabla f|= |f_{x}| + |f_{y}|$
\begin{itemize}
\item Magnitude of a gradient at pixel $(u,v)$ tells us the rate of change of intensities at $(u,v)$
\item In other words, it tells us the edge passing $(u,v)$ is strong or not.
\end{itemize}
\end{block}
}
\frame
{
\frametitle{Gradient}
\selectlanguage{english}
\begin{block}{Magnitude and angle of gradient vectors}
\textbf{Angle} of gradient is computed by:
$\theta(\nabla f)= $
$tan^{-1}(\frac{f_{y}}{f_{x}})$
\begin{itemize}
\item Angle of a gradient at pixel $(u,v)$ tells us the orientation of edge passing $(u,v)$
\item Gradient vector is perpendicular to the local edge passing $(u,v)$
\end{itemize}
\end{block}
}
\begin{frame}[fragile]
\frametitle{First-Order derivative of image}
\selectlanguage{english}
\begin{exercise}
\begin{figure}[!h]
\includegraphics[scale=0.25]{checkboard.png}
\caption{a chessboard}
\end{figure}
\begin{itemize}
\item How do we create an image emphasizing both of horizontal and vertical edges the above chessboard?
\item Which is the direction of gradient vectors at strong edge points?
\end{itemize}
\end{exercise}
\end{frame}
\section{Second-order derivative}
\frame
{
\frametitle{Second-order Derivative of one variable function}
\selectlanguage{english}
Second-order differential can be approximated by
\begin{align}
\nonumber
f^{''}(x) \cong f^{'}(x) - f^{'}(x+1)
\end{align}
First-order derivatives can be approximated as
\begin{align}
\nonumber
f^{'}(x) &\cong f(x) - f(x-1) \\
\nonumber
f^{'}(x+1) &\cong f(x+1) - f(x)
\end{align}
\begin{alertblock}{Second-order derivative}
\begin{align}
\nonumber
f^{''}(x) \cong -f^{'}(x-1) + 2f^{'}(x) - f(x+1)
\end{align}
\end{alertblock}
}
\frame
{
\frametitle{Second-Order derivative of image}
\selectlanguage{english}
\begin{enumerate}
\item Second-order derivative on x
\begin{itemize}
\item Math:
\begin{align}
\nonumber
\frac{\partial^{2} f(x,y)}{\partial x^2} = -f(x-1, y) + 2f(x,y) - f(x+1,y)
\end{align}
\item Kernel: $H_{conv} = $ $\left[ \begin{array}{rrr} -1 & 2 & -1 \end{array}\right] $
\end{itemize}
\item Second-order derivative on y
\begin{itemize}
\item Math:
\begin{align}
\nonumber
\frac{\partial^{2} f(x,y)}{\partial y^2} = -f(x, y-1) + 2f(x,y) - f(x,y+1)
\end{align}
\item Kernel: $H_{conv} = $ $\left[ \begin{array}{r} -1 \\ 2 \\ -1 \end{array}\right]$
\end{itemize}
\end{enumerate}
}
\frame
{
\frametitle{Second-Order derivative of image}
\selectlanguage{english}
In general, second-order derivatives can be approximated by using the following kernels.
\newline
\centering
\small
\begin{tabular}{|l|l|l|}
\hline
&Derivative on x & Derivative on y \\
\hline
& & \\
Positive at center: &
$H_{x} = $ $\left[ \begin{array}{rrr} -1 & 2 & -1 \end{array}\right] $ &
$H_{y} = $ $\left[ \begin{array}{r} -1 \\ 2 \\ -1 \end{array}\right]$\\
& & \\
\hline
& & \\
Negative at center: &
$H_{x} = $ $\left[ \begin{array}{rrr} 1 & -2 & 1 \end{array}\right] $ &
$H_{y} = $ $\left[ \begin{array}{r} 1 \\ -2 \\ 1 \end{array}\right]$\\
& & \\
\hline
\end{tabular}
}
\frame
{
\frametitle{First-order and Second-order derivative}
\selectlanguage{english}
\begin{figure}[!h]
\includegraphics[scale=0.6]{derivatives.png}
\caption{Example of First-order and Second-order derivatives }
\end{figure}
}
\frame
{
\frametitle{First-order and Second-order derivative}
\selectlanguage{english}
\begin{alertblock}{First-order derivative's properties}
\begin{enumerate}
\item First-order derivatives produce \alert{\textbf{thicker edge}} in an image.
\item First-order derivatives produce \alert{\textbf{strong response}} to a gray-level step.
\end{enumerate}
\end{alertblock}
\begin{alertblock}{Second-order derivative's properties}
\begin{enumerate}
\item Second-order derivatives produce \alert{\textbf{stronger response}} to fine detail, such as thin lines or isolated points (noise).
\item Second-order derivatives produce \alert{\textbf{double response}} (a \alert{\textbf{positive}} and a \alert{\textbf{negative}}) at step change in in gray level.
\item \alert{\textbf{Zero-crossing}} at a point in second-order derivatives indicates that there is an edge passing that point.
\end{enumerate}
\end{alertblock}
}
\section{Laplacian}
\frame
{
\frametitle{Second-Order derivative of image}
\selectlanguage{english}
\alert{\textbf{Second-order derivative on x and y}}
Laplacian operator:
\begin{align}
\nonumber
\nabla^{2}f = \frac{\partial^{2} f(x,y)}{\partial x^2} + \frac{\partial^{2} f(x,y)}{\partial y^2}
\end{align}
\begin{itemize}
\item Math:
\begin{align}
\nonumber
\nabla^{2}f & = &-f(x-1, y) + 2f(x,y) - f(x+1,y) \\
\nonumber
&&-f(x, y-1) + 2f(x,y) - f(x,y+1)
\end{align}
\item Kernel: $H_{lap} = $ $\left[
\begin{array}{rrr}
0 & -1 & 0 \\
-1 & 4 & -1\\
0 & -1 & 0
\end{array}\right] $
\end{itemize}
}
\frame
{
\frametitle{Second-Order derivative of image}
\selectlanguage{english}
\alert{\textbf{Second-order derivative on x, y, and diagonals:}}
Extended Laplacian operator:
\begin{itemize}
\item Math:
\begin{align}
\nonumber
\nabla^{2}f & = &-f(x-1, y) + 2f(x,y) - f(x+1,y) \\
\nonumber
&&-f(x, y-1) + 2f(x,y) - f(x,y+1)
\end{align}
\item Kernel: $H_{lap} = $ $\left[
\begin{array}{rrr}
-1 & -1 & -1 \\
-1 & 8 & -1\\
-1 & -1 & -1
\end{array}\right] $
\end{itemize}
}
\frame
{
\frametitle{Second-Order derivative of image}
\selectlanguage{english}
In general, Laplician can be computed by using the following kernels. The center coefficients maybe positive or negative.
\newline
\centering
\begin{tabular}{|l||l|}
\hline
& \\
$H_{lap} = $ $\left[
\begin{array}{rrr}
0 & -1 & 0 \\
-1 & 4 & -1\\
0 & -1 & 0
\end{array}\right] $
&
$H_{lap} = $ $\left[
\begin{array}{rrr}
-1 & -1 & -1 \\
-1 & 8 & -1\\
-1 & -1 & -1
\end{array}\right] $ \\
& \\
\hline
& \\
$H_{lap} = $ $\left[
\begin{array}{rrr}
0 & 1 & 0 \\
1 & -4 & 1\\
0 & 1 & 0
\end{array}\right] $
&
$H_{lap} = $ $\left[
\begin{array}{rrr}
1 & 1 & 1 \\
1 & -8 & 1\\
1 & 1 & 1
\end{array}\right] $ \\
& \\
\hline
\end{tabular}
}
\section{Applications of Laplacican}
\frame
{
\frametitle{Applications of Laplacican operator}
\begin{alertblock}{Properties of Laplacican operators}
\begin{enumerate}
\item \textbf{Highlight} gray-level discontinues in images, i.e., edges on images
\item \textbf{De-emphasize} regions with slowly varying gray-levels
\end{enumerate}
Therefore, adding (or subtracting) the original image with Laplacian image (the image obtained by filtering the original with Laplacian kernel) $\Rightarrow$ \alert{\textbf{Sharpened images}}
\end{alertblock}
}
\frame
{
\frametitle{Applications of Laplacican operator}
Method for sharpening image $f(x,y)$:
\flushleft
$$
g(x,y) =
\begin{cases}
f(x,y) - \nabla^2f(x,y)& \text{if the center coefficient of the}\\
& \text{Laplacian mask is negative }\\
f(x,y) + \nabla^2f(x,y)& \text{if the center coefficient of the} \\
& \text{Laplacian mask is positive }
\end{cases}
$$
}
\frame
{
\frametitle{Second-Order derivative of image}
\selectlanguage{english}
Method for sharpening image $f(x,y)$ by using linear filters. Kernels are as follows:
\newline
\begin{tabular}{|l|l|}
\hline
\textbf{Positive central coefficient} & \textbf{Positive central coefficient} \\
\hline
& \\
$H_{Lap} = $ $\left[
\begin{array}{rrr}
-1 & -1 & -1 \\
-1 & 9 & -1\\
-1 & -1 & -1
\end{array}\right] $ &
$H_{Lap} = $ $\left[
\begin{array}{rrr}
1 & 1 & 1 \\
1 & -9 & 1\\
1 & -1 & 1
\end{array}\right] $ \\
& \\
\hline
& \\
$H_{Lap} = $ $\left[
\begin{array}{rrr}
0 & -1 & 0 \\
-1 & 5 & -1\\
0 & -1 & 0
\end{array}\right] $ &
$H_{Lap} = $ $\left[
\begin{array}{rrr}
0 & 1 & 0 \\
1 & -5 & 1\\
0 & -1 & 0
\end{array}\right] $ \\
& \\
\hline
\end{tabular}
}
\frame
{
\frametitle{Applications of Laplacican operator: Examples}
\selectlanguage{english}
\begin{figure}[!h]
\includegraphics[scale=0.4]{north_pole.jpg}
\caption{Input image: North pole of moon}
\end{figure}
}
\frame
{
\frametitle{Applications of Laplacican operator: Examples}
\selectlanguage{english}
\begin{figure}[!h]
\begin{tabular}{cc}
\includegraphics[scale=0.5]{north_pole_laplacian_unscaled.png} &
\includegraphics[scale=0.5]{north_pole_laplacian_scaled.png} \\
(a) & (b)
\end{tabular}
\centering
\caption{Laplacian images = images obtained by filtering with Laplacian operator: (a) without scaling, (b) with scaling for display purpose}
\end{figure}
}
\frame
{
\frametitle{Applications of Laplacican operator: Exercises}
\selectlanguage{english}
\begin{exercise}
\begin{enumerate}
\item How can you sharpen images, e.g., north pole of moon, with Laplacian by using Matlab and OpenCV?
\item Create blurred version and then sharpen the blurred version
\begin{itemize}
\item Read checkboard image from file
\item Blur it with Box or Gaussian filter
\item Sharpen the resulting blurred version with Laplacian
\item Show the original, blurred version and sharpened version.
\end{itemize}
\end{enumerate}
\end{exercise}
}
\frame
{
\frametitle{Unsharp masking and High-boost filtering}
\selectlanguage{english}
\textbf{Unsharp masking:} image obtained from subtracting a blurred version of an image from the image itself.
\begin{align}
\nonumber
f_s(x,y) &= f(x,y) - \bar{f}(x,y)
\end{align}
\begin{itemize}
\item $\bar{f}(x,y)$ : blurred version of $f(x,y)$, e.g., using box filter
\item $f_s(x,y)$: sharpened image
\end{itemize}
}
\frame
{
\frametitle{Unsharp masking and High-boost filtering}
\selectlanguage{english}
\begin{exercise}
\begin{enumerate}
\item How can you implement unsharp masking with Matlab and OpenCV?
\item Create blurred version and then sharpen the blurred version
\begin{itemize}
\item Read checkboard image from file
\item Blur it with Box or Gaussian filter
\item Sharpen the resulting blurred version with Unsharp masking
\item Show the original, blurred version and sharpened version.
\end{itemize}
\end{enumerate}
\end{exercise}
}
\frame
{
\frametitle{Unsharp masking and High-boost filtering}
\selectlanguage{english}
\textbf{High-boost filtering:} a generalized unsharpened image.
\begin{align}
\nonumber
f_{hb}(x,y) &= Af(x,y) - \bar{f}(x,y)
\end{align}
\begin{itemize}
\item $A$ : a parameter, $A \ge 1$. $A=1$, hight-boost filtering $\rightarrow$ unsharp masking
\item $f_s(x,y)$: sharpened image
\end{itemize}
}
\frame
{
\frametitle{Unsharp masking and High-boost filtering}
\selectlanguage{english}
\textbf{High-boost filtering:} Other representations.
\begin{align}
\nonumber
f_{hb}(x,y) &= Af(x,y) - \bar{f}(x,y)\\
\nonumber
&= (A-1)f(x,y) + f(x,y) - \bar{f}(x,y)\\
&= (A-1)f(x,y) + f_s(x,y) \label{eq:hb_filter}
\end{align}
Replace Eq. (\ref{eq:hb_filter}) with Laplacian sharpening filter:
\small
$$
f_{hb}(x,y) =
\begin{cases}
Af(x,y) - \nabla^2f(x,y)& \text{if the center coefficient of the}\\
& \text{Laplacian mask is negative }\\
Af(x,y) + \nabla^2f(x,y)& \text{if the center coefficient of the} \\
& \text{Laplacian mask is positive }
\end{cases}
$$
}
\frame
{
\frametitle{Unsharp masking and High-boost filtering}
\selectlanguage{english}
\textbf{High-boost filtering:} can be implemented as a linear filter, with one of the following kernels.
\newline
\newline
\centering
\begin{tabular}{l||l}
\\
$H_{hb8} = $ $\left[
\begin{array}{rrr}
-1 & -1 & -1 \\
-1 & A+8 & -1\\
-1 & -1 & -1
\end{array}\right] $ &
$H_{hb4} = $ $\left[
\begin{array}{rrr}
0 & -1 & 0 \\
-1 & A+4 & -1\\
0 & -1 & 0
\end{array}\right] $ \\
\\
\end{tabular}
\flushleft
\textbf{$A$ is a parameter:}
\begin{enumerate}
\item $A=0$, hight-boost filter becomes standard \alert{Laplacian filter}
\item $A=1$, hight-boost filter becomes standard \alert{Laplacian sharpening filter}
\item $A$ increases pass $1$ the contribution of sharpening process becomes less and less important
\end{enumerate}
}
\frame
{
\frametitle{Unsharp masking and High-boost filtering}
\selectlanguage{english}
\begin{alertblock}{Applications of High-boost filtering:}
\begin{itemize}
\item High-boost filtering can sharpen images
\item High-boost filtering can brighten dark images
\end{itemize}
\end{alertblock}
}
\frame
{
\frametitle{Unsharp masking and High-boost filtering: Examples}
\selectlanguage{english}
\begin{figure}[!h]
\includegraphics[scale=0.75]{highboost.png}
\end{figure}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 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: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 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: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 423 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 268 KiB