向下移动图形标签

向下移动图形标签

源代码和来源: https://github.com/PetarV-/TikZ/blob/master/2D%20Convolution/2d_convolution.tex#L6

我修改后的代码:

\begin{figure} [h]
    \centering
    \begin{tikzpicture}
    \matrix (mtr) [matrix of nodes,row sep=-\pgflinewidth, nodes={draw}]
    {
        0 & 1 & 1 & |[fill=red!30]| 1 & |[fill=red!30]| 0 & |[fill=red!30]| 0 & 0\\
        0 & 0 & 1 & |[fill=red!30]| 1 & |[fill=red!30]| 1 & |[fill=red!30]| 0 & 0\\
        0 & 0 & 0 & |[fill=red!30]| 1 & |[fill=red!30]| 1 & |[fill=red!30]| 1 & 0\\
        0 & 0 & 0 & 1 & 1 & 0 & 0\\
        0 & 0 & 1 & 1 & 0 & 0 & 0\\
        0 & 1 & 1 & 0 & 0 & 0 & 0\\
        1 & 1 & 0 & 0 & 0 & 0 & 0\\
    };
    \draw[very thick, red] (mtr-1-4.north west) rectangle (mtr-3-6.south east);
    \node [below= of mtr-5-4.south] (lm) {$\bf I$};
    \node[right = 0.2em of mtr] (str) {$*$};
    \matrix (K) [right=0.2em of str,matrix of nodes,row sep=-\pgflinewidth, nodes={draw, fill=blue!30}]
    {
        1 & 0 & 1 \\
        0 & 1 & 0 \\
        1 & 0 & 1 \\
    };
    \node [below = of K-3-2.south] (lk) {$\bf K$};
    \node [right = 0.2em of K] (eq) {$=$};
    \matrix (ret) [right=0.2em of eq,matrix of nodes,row sep=-\pgflinewidth, nodes={draw}]
    {
        1 & 4 & 3 & |[fill=yellow!30]| 4 & 1\\
        1 & 2 & 4 & 3 & 3\\
        1 & 2 & 3 & 4 & 1\\
        1 & 3 & 3 & 1 & 1\\
        3 & 3 & 1 & 1 & 0\\
    };
    \node [below = of ret-4-3.south] (lim) {${\bf I} * {\bf K}$};
    \draw[very thick, orange] (ret-1-4.north west) rectangle (ret-1-4.south east);
    \draw[densely dotted, blue, thick] (mtr-1-4.north west) -- (K-1-1.north west);
    \draw[densely dotted, blue, thick] (mtr-3-4.south west) -- (K-3-1.south west);
    \draw[densely dotted, blue, thick] (mtr-1-6.north east) -- (K-1-3.north east);
    \draw[densely dotted, blue, thick] (mtr-3-6.south east) -- (K-3-3.south east);
    \draw[densely dotted, orange, thick] (ret-1-4.north west) -- (K-1-1.north west);
    \draw[densely dotted, orange, thick] (ret-1-4.south west) -- (K-3-1.south west);
    \draw[densely dotted, orange, thick] (ret-1-4.north east) -- (K-1-3.north east);
    \draw[densely dotted, orange, thick] (ret-1-4.south east) -- (K-3-3.south east);
    \matrix (K) [right=0.2em of str,matrix of nodes,row sep=-\pgflinewidth, nodes={draw, fill=blue!10}]
    {
        1 & 0 & 1 \\
        0 & 1 & 0 \\
        1 & 0 & 1 \\
    };
    \draw[very thick, blue] (K-1-1.north west) rectangle (K-3-3.south east);
    \node[anchor=south east, inner sep=0.01em, blue] at (mtr-1-4.south east) (xx) {\scalebox{.5}{$\times 1$}};
    \node[anchor=south east, inner sep=0.01em, blue] at (mtr-1-5.south east) (xx) {\scalebox{.5}{$\times 0$}};
    \node[anchor=south east, inner sep=0.01em, blue] at (mtr-1-6.south east) (xx) {\scalebox{.5}{$\times 1$}};
    \node[anchor=south east, inner sep=0.01em, blue] at (mtr-2-4.south east) (xx) {\scalebox{.5}{$\times 0$}};
    \node[anchor=south east, inner sep=0.01em, blue] at (mtr-2-5.south east) (xx) {\scalebox{.5}{$\times 1$}};
    \node[anchor=south east, inner sep=0.01em, blue] at (mtr-2-6.south east) (xx) {\scalebox{.5}{$\times 0$}};
    \node[anchor=south east, inner sep=0.01em, blue] at (mtr-3-4.south east) (xx) {\scalebox{.5}{$\times 1$}};
    \node[anchor=south east, inner sep=0.01em, blue] at (mtr-3-5.south east) (xx) {\scalebox{.5}{$\times 0$}};
    \node[anchor=south east, inner sep=0.01em, blue] at (mtr-3-6.south east) (xx) {\scalebox{.5}{$\times 1$}};
    \end{tikzpicture}
    \caption{2D convolutional operator where the kernel matrix is moved across the target image and element-wise products are recorded.}
    \label{fig:my_label}
\end{figure}

输出:

在此处输入图片描述

问题:如何添加空格/向下移动标签在第一个区块下?标签需要向下移动。谢谢您的帮助!

答案1

上面的代码编译得很好,第一个矩阵和它的预期差距很大label I——仍然面临的问题——修改行——尺寸\node [below= of mtr-5-4.south] (lm) {$\bf I$};可以根据选择而变化——\node [below= 2pt of mtr-5-4.south] (lm) {$\bf I$};2pt

如果你编辑了上面的行,你还必须适当地编辑label K和的行label I*K

相关内容