Files
phd-thesis-beamer/img/animation/conv.tex
2020-12-01 09:39:37 +01:00

55 lines
1.7 KiB
TeX

\documentclass[10pt,tikz]{standalone}
\usepackage{tikz}
\usepackage{ifthen}
\newlength{\cell}
\setlength{\cell}{1cm}
\newlength{\separation}
\setlength{\separation}{3cm}
\begin{document}
\foreach \m in {0,...,9}
{
\foreach \n in {0,...,7}
{
\begin{tikzpicture}
% draw main grid
\draw[thick] (0,0) rectangle (10 * \cell, 12 * \cell);
\foreach \x in {0,...,9}
{
\foreach \y in {0,...,11}
{
\draw (\x * \cell, \y * \cell) rectangle (\x * \cell + \cell, \y * \cell + \cell);
}
}
\node[anchor=base] at (5 * \cell, -\cell) {INPUT};
% draw convolution
\draw[thick, fill=red!20, opacity=0.5] (\n * \cell, 12 * \cell - \m * \cell) rectangle (\n * \cell + 3 * \cell, 12 * \cell - 3 * \cell - \m * \cell);
\draw[fill=red!20, opacity=0.5] (\n * \cell + 10 * \cell + \separation, 9 * \cell - \m * \cell) rectangle (\n * \cell + 10 * \cell + \separation + \cell, 9 * \cell + \cell - \m * \cell);
\draw[thick, red] (\n * \cell + 1.5 * \cell, 12 * \cell - \m * \cell) -- (\n * \cell + 10 * \cell + \separation + 0.5 * \cell, 10 * \cell - 0.5 * \cell - \m * \cell) -- (\n * \cell + 1.5 * \cell, 9 * \cell - \m * \cell);
% draw filter
\draw[thick] (10 * \cell + \separation, 0) rectangle (18 * \cell + \separation, 10 * \cell);
\foreach \x in {0,...,7}
{
\foreach \y in {0,...,9}
{
\draw (10 * \cell + \separation + \x * \cell, \y * \cell) rectangle (10 * \cell + \separation + \x * \cell + \cell, \y * \cell + \cell);
}
}
\node[anchor=base] at (10 * \cell + \separation + 4 * \cell, -\cell) {OUTPUT};
\end{tikzpicture}
}
}
\end{document}