我试图添加一些矩阵来显示同一图像上的卷积变换,但其中一个矩阵是 5x5,其他的是 3x3。问题是我无法保持图像完美对齐。
編輯:
以下是代码:
\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{amsmath}
\begin{document}
\begin{figure}[htb!]
\centering
\begin{subfigure}[b]{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{figs/random.eps}
\caption[Network2]%
{{\small $\left(\begin{smallmatrix}1&0&1&0&1\\0&1&0&1&0\\1&0&-4&0&1\\0&1&0&1&0\\1&0&1&0&1\end{smallmatrix}\right)$}}
\label{fig:rand}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{figs/sharpen.eps}
\caption[]%
{{\small $\left(\begin{smallmatrix}0&-1&0\\-1&5&-1\\0&-1&0\end{smallmatrix}\right)$}}
\label{fig:sharpen}
\end{subfigure}
\vskip\baselineskip
\begin{subfigure}[b]{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{figs/edge_5.eps}
\caption[]%
{{\small $\left(\begin{smallmatrix}1&0&-1\\0&0&0\\-1&0&0\end{smallmatrix}\right)$}}
\label{fig:edge_5}
\end{subfigure}
\quad
\begin{subfigure}[b]{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{figs/edge_8.eps}
\caption[]%
{{\small $\left(\begin{smallmatrix}-1&-1&-1\\-1&8&-1\\-1&-1&-1\end{smallmatrix}\right)$}}
\label{fig:mean and std of net44}
\end{subfigure}
\caption[ Transformation of original image]
{\small Several convolution transformation of the original image. Each kernel gives a different configuration}
\label{fig:edge_8}
\end{figure}
\end{document}
结果:
我应该怎么办?
问候!
答案1
让我将我的评论转换为答案:
- 图像高度相同的情况
\documentclass{article}
\usepackage{mathtools}
\usepackage[font=small]{caption, subcaption}
\usepackage[demo]{graphicx}
\begin{document}
\begin{figure}[htb!]
\centering
\begin{subfigure}[t]{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{figs/random.eps}
\caption[Network2]%
{$\left(\begin{smallmatrix}1&0&1&0&1\\0&1&0&1&0\\1&0&-4&0&1\\0&1&0&1&0\\1&0&1&0&1\end{smallmatrix}\right)$}
\label{fig:rand}
\end{subfigure}
\hfil
\begin{subfigure}[t]{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{figs/sharpen.eps}
\caption[]%
{{\small $\left(\begin{smallmatrix}0&-1&0\\-1&5&-1\\0&-1&0\end{smallmatrix}\right)$}}
\label{fig:sharpen}
\end{subfigure}
\vskip\baselineskip
\begin{subfigure}[t]{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{figs/edge_5.eps}
\caption[]%
{$\left(\begin{smallmatrix}1&0&-1\\0&0&0\\-1&0&0\end{smallmatrix}\right)$}
\label{fig:edge_5}
\end{subfigure}
\hfil
\begin{subfigure}[t]{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{figs/edge_8.eps}
\caption[]%
{$\left(\begin{smallmatrix}-1&-1&-1\\-1&8&-1\\-1&-1&-1\end{smallmatrix}\right)$}
\label{fig:mean and std of net44}
\end{subfigure}
\caption[ Transformation of original image]
{Several convolution transformation of the original image. Each kernel gives a different configuration}
\label{fig:edge_8}
\end{figure}
\end{document}
- 图像高度不同的情况
\documentclass{article}
\usepackage{mathtools}
\usepackage[font=small]{caption, subcaption}
\usepackage[demo]{graphicx}
\begin{document}
\begin{figure}[htb!]
\centering
\begin{subfigure}[t]{0.45\textwidth}
\includegraphics[width=\textwidth,height=43mm]{figs/random.eps}
\caption[Network2]%
{$\left(\begin{smallmatrix}1&0&1&0&1\\0&1&0&1&0\\1&0&-4&0&1\\0&1&0&1&0\\1&0&1&0&1\end{smallmatrix}\right)$}
\label{fig:rand}
\end{subfigure}
\hfil
\begin{subfigure}[t]{0.45\textwidth}
\includegraphics[width=\textwidth,height=34mm]{figs/sharpen.eps}
\caption[]%
{{\small $\left(\begin{smallmatrix}0&-1&0\\-1&5&-1\\0&-1&0\end{smallmatrix}\right)$}}
\label{fig:sharpen}
\end{subfigure}
\vskip\baselineskip
\begin{subfigure}[t]{0.45\textwidth}
\includegraphics[width=\textwidth]{figs/edge_5.eps}
\caption[]%
{$\left(\begin{smallmatrix}1&0&-1\\0&0&0\\-1&0&0\end{smallmatrix}\right)$}
\label{fig:edge_5}
\end{subfigure}
\hfil
\begin{subfigure}[t]{0.45\textwidth}
\includegraphics[width=\textwidth]{figs/edge_8.eps}
\caption[]%
{$\left(\begin{smallmatrix}-1&-1&-1\\-1&8&-1\\-1&-1&-1\end{smallmatrix}\right)$}
\label{fig:mean and std of net44}
\end{subfigure}
\caption[ Transformation of original image]
{Several convolution transformation of the original image. Each kernel gives a different configuration}
\label{fig:edge_8}
\end{figure}
\end{document}
- 如果图像有不同的高度,但您希望以相同的高度显示,则定义它们的高度:
\begin{subfigure}[t]{0.45\textwidth}
\includegraphics[width=\textwidth, height=44mm]{figs/random.eps}
\caption[Network2]%
{$\left(\begin{smallmatrix}1&0&1&0&1\\0&1&0&1&0\\1&0&-4&0&1\\0&1&0&1&0\\1&0&1&0&1\end{smallmatrix}\right)$}
\label{fig:rand}
\end{subfigure}
\hfil
\begin{subfigure}[t]{0.45\textwidth}
\includegraphics[width=\textwidth,height=44mm]{figs/sharpen.eps}
\caption[]%
{{\small $\left(\begin{smallmatrix}0&-1&0\\-1&5&-1\\0&-1&0\end{smallmatrix}\right)$}}
\label{fig:sharpen}
\end{subfigure}