Page MenuHomec4science

2_affine.tex
No OneTemporary

File Metadata

Created
Sat, Mar 15, 10:48

2_affine.tex

\documentclass[aspectratio=169]{beamer}
\def\stylepath{../../styles}
\usepackage{\stylepath/com303}
\begin{document}
\begin{frame}
\frametitle{Affine transforms}
\centering
mapping $\mathbb{R}^2 \rightarrow \mathbb{R}^2$ that reshapes the coordinate system:
\[
\begin{bmatrix} t'_1 \\ t'_2 \end{bmatrix} =
\begin{bmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{bmatrix} \begin{bmatrix} t_1 \\ t_2 \end{bmatrix} - \begin{bmatrix} d_1 \\ d_2 \end{bmatrix}
\]
\pause
\vspace{2em}
\[
\begin{bmatrix} t'_1 \\ t'_2 \end{bmatrix} = \mathbf{A} \begin{bmatrix} t_1 \\ t_2 \end{bmatrix} - \mathbf{d}
\]
\end{frame}
\def\flag{\psline(-.5,-1)(-.5,1.2)(1,1.2)(0.5,0.7)(1,0.2)(-.5,0.2)}
\def\grayFlag{\psline[linecolor=lightgray](-.5,-1)(-.5,1.2)(1,1.2)(0.5,0.7)(1,0.2)(-.5,0.2)}
\begin{frame}
\frametitle{Translation}
\begin{columns}
\begin{column}{0.45\paperwidth}
\begin{align*}
\mathbf{A} &= \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} = \mathbf{I} \\
\mathbf{d} &= \begin{bmatrix} d_1 \\ d_2 \end{bmatrix}
\end{align*}
\end{column}
\begin{column}{0.45\paperwidth}
\begin{figure}
\begin{center}
\begin{dspCP}[width=5cm,xticks=5,yticks=5,xout=true]{-3,3}{-3,3}
\moocStyle
\only<1>{\flag}
\only<2>{%
\grayFlag
\rput(0.7,0.3){\flag}}
\end{dspCP}
\end{center}
\end{figure}
\end{column}
\end{columns}
\end{frame}
\begin{frame}
\frametitle{Scaling}
\begin{columns}
\begin{column}{0.45\paperwidth}
\begin{align*}
\mathbf{A} &= \begin{bmatrix} a_1 & 0 \\ 0 & a_2 \end{bmatrix} \\
\mathbf{d} &= 0
\end{align*}
\vspace{1em}
if $a_1 = a_2$ the {\em aspect ratio} is preserved
\end{column}
\begin{column}{0.45\paperwidth}
\begin{figure}
\begin{center}
\begin{dspCP}[width=5cm,xticks=5,yticks=5,xout=true]{-3,3}{-3,3}
\moocStyle
\only<1>{\flag}
\only<2>{%
\grayFlag
\psscalebox{1.5}{\flag}}
\end{dspCP}
\end{center}
\end{figure}
\end{column}
\end{columns}
\end{frame}
\begin{frame}
\frametitle{Rotation}
\begin{columns}
\begin{column}{0.45\paperwidth}
\begin{align*}
\mathbf{A} &= \begin{bmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{bmatrix} \\
\mathbf{d} &= 0
\end{align*}
\end{column}
\begin{column}{0.45\paperwidth}
\begin{figure}
\begin{center}
\begin{dspCP}[width=5cm,xticks=5,yticks=5,xout=true]{-3,3}{-3,3}
\moocStyle
\only<1>{\flag}
\only<2>{%
\grayFlag
\rput{110}{\flag}}
\only<3>{%
\grayFlag
\rput{180}{\flag}}
\end{dspCP}
\end{center}
\end{figure}
\end{column}
\end{columns}
\end{frame}
\begin{frame}
\frametitle{Flips}
\begin{columns}
\begin{column}{0.45\paperwidth}
Horizontal:
\begin{align*}
\mathbf{A} &= \begin{bmatrix} -1 & 0 \\ 0 & 1 \end{bmatrix} \\
\mathbf{d} &= 0
\end{align*}
Vertical:
\begin{align*}
\mathbf{A} &= \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix} \\
\mathbf{d} &= 0
\end{align*}
\end{column}
\begin{column}{0.45\paperwidth}
\begin{figure}
\begin{center}
\begin{dspCP}[width=5cm,xticks=5,yticks=5,xout=true]{-3,3}{-3,3}
\moocStyle
\only<1>{\flag}
\only<2>{
\grayFlag
\psscalebox{-1 1}{\flag}}
\end{dspCP}
\end{center}
\end{figure}
\end{column}
\end{columns}
\end{frame}
\begin{frame}
\frametitle{Shear}
\begin{columns}
\begin{column}{0.45\paperwidth}
Horizontal:
\begin{align*}
\mathbf{A} &= \begin{bmatrix} 1 & s \\ 0 & 1 \end{bmatrix} \\
\mathbf{d} &= 0
\end{align*}
Vertical:
\begin{align*}
\mathbf{A} &= \begin{bmatrix} 1 & 0 \\ s & 1 \end{bmatrix} \\
\mathbf{d} &= 0
\end{align*}
\end{column}
\begin{column}{0.45\paperwidth}
\begin{figure}
\begin{center}
\begin{dspCP}[width=5cm,xticks=5,yticks=5,xout=true]{-3,3}{-3,3}
\moocStyle
\only<1>{\flag}
\only<2>{
\grayFlag
\def\s{0.5 }
\psline(! -.5 -1 dup \s mul 3 -1 roll add exch)(! -.5 1.2 dup \s mul 3 -1 roll add exch)(! 1 1.2 dup \s mul 3 -1 roll add exch)(! 0.5 0.7 dup \s mul 3 -1 roll add exch)(! 1 0.2 dup \s mul 3 -1 roll add exch)(! -.5 0.2 dup \s mul 3 -1 roll add exch)}
\end{dspCP}
\end{center}
\end{figure}
\end{column}
\end{columns}
\end{frame}
\begin{frame}
\frametitle{Affine transforms in discrete-space}
\[
\begin{bmatrix} t'_1 \\ t'_2 \end{bmatrix} = \mathbf{A} \begin{bmatrix} n_1 \\ n_2 \end{bmatrix} - \mathbf{d} \quad {\color{red} \in \mathbb{R}^2 \neq \mathbb{Z}^2}
\]
\end{frame}
\begin{frame}
\frametitle{Solution for images}
\begin{itemize}[<+->]
\item take each {\em output point} $y[m_1, m_2]$
\item apply the {\em inverse} transform to $[m_1, m_2]$ and find the {\em source} point's coordinates:
\[
\begin{bmatrix} t_1 \\ t_2 \end{bmatrix} = \mathbf{A}^{-1} \begin{bmatrix} m_1 + d_1 \\ m_2 + d_2 \end{bmatrix};
\]
\item if source point not on source grid, write
\[
(t_1, t_2) = (\eta_1 + \tau_1, \eta_2 + \tau_2), \qquad \eta_{1,2} \in \mathbb{Z}, \quad 0 \le \tau_{1,2} < 1
\]
and interpolate from the surrounding original grid points
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Bilinear Interpolation}
\begin{figure}\label{bilinearInt}
\begin{center}
\begin{dspCP}[width=6cm,xticks=custom,yticks=custom,xout=true]{0.5,2.5}{0.5,2.5}
\only<1-2>{
\dspPointValue[linecolor=blue]{2,2}{$x[\eta_1+1,\eta_2+1]$}
\dspPointValue[linecolor=blue]{1,1}{$x[\eta_1,\eta_2]$}}
\only<3->{
\dspPointValue[linecolor=blue]{2,2}{}
\dspPointValue[linecolor=blue]{1,1}{}}
\dspPointValue[linecolor=blue]{2,1}{}
\dspPointValue[linecolor=blue]{1,2}{}
%
\only<2>{\dspPointValue[linecolor=red]{1.3,1.7}{$(t_1,t_2)$}}
\only<3->{\dspPointValue[linecolor=red]{1.3,1.7}{}}
%
\only<3->{\psline[linewidth=0.5pt]{<->}(1,1)(1.3,1)\dspText(1.14,0.9){$\tau_1$}}
\only<3,5->{\psline[linewidth=0.5pt]{<->}(1.3,1)(1.3,1.7)\dspText(1.4,1.3){$\tau_2$}}
%
\only<4->{
\psline[linewidth=0.5pt,linestyle=dotted](1,1)(2,1)
\psline[linewidth=0.5pt,linestyle=dotted](1,2)(2,2)
\dspPointValue[dotstyle=triangle*,linecolor=green]{1.3,1}{}
\dspPointValue[dotstyle=triangle*,linecolor=green]{1.3,2}{}}
%
\only<5->{
\psline[linewidth=0.5pt,linestyle=dotted](1.3,1)(1.3,2)}
%
\dspCustomTicks[axis=x]{1 $\eta_1$ 2 $\eta_1+1$}
\dspCustomTicks[axis=y]{1 $\eta_2$ 2 $\eta_2+1$}
\end{dspCP}
\end{center}
\end{figure}
\end{frame}
\begin{frame}
\frametitle{Bilinear Interpolation}
If we use a first-order interpolator:
\begin{align*}
y[m_1,m_2] &= (1-\tau_1)(1-\tau_2)x[\eta_1, \eta_2] + \tau_1(1-\tau_2)x[\eta_1+1, \eta_2] \\
& + (1-\tau_1)\tau_2x[\eta_1, \eta_2+1] + \tau_1\tau_2x[\eta_1+1, \eta_2+1]
\end{align*}
\end{frame}
\begin{frame}
\frametitle{Shearing}
\begin{figure}
\includegraphics[height=6cm]{\imagePath/shear.eps}%
\end{figure}
\end{frame}
\end{document}

Event Timeline