![画一个带有两个箭头的图形](https://linux22.com/image/436884/%E7%94%BB%E4%B8%80%E4%B8%AA%E5%B8%A6%E6%9C%89%E4%B8%A4%E4%B8%AA%E7%AE%AD%E5%A4%B4%E7%9A%84%E5%9B%BE%E5%BD%A2.png)
我想画出附图,但是我不知道如何添加两个箭头以及如何在箭头上标注名称。你能帮我吗?提前谢谢了。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows.meta,decorations, positioning, arrows.meta, calc, shapes.geometric}
\begin{document}
\begin{tikzpicture}[block/.style={draw, fill=blue!15, rectangle, minimum height=1.7em, minimum width=2em},
blockev/.style={draw, fill=blue!15, rectangle, minimum height=1.8cm, minimum width=1.8cm},
blocksmallev/.style={draw, fill=blue!15, rectangle, minimum height=1.8cm, minimum width=1.2cm},
input/.style={coordinate},
arr/.style = {-Stealth},
\node [blockev, minimum height =2.5cm, minimum width=3.5cm, label={[above, very thick, font = \large]}](celll) at (-1.26,-2.74){} ;
\node[input, name = input, font = \normalsize] (input){};
\node[blockev, right = 0.4cm of input, font = \normalsize] (feature) {\textbf{Feature} \textbf{extraction}};
\node[blocksmallev, left = 0.35cm of feature, font = \normalsize] (segmen) {{\shortstack{\textbf{Segmentation}\\ \textbf{Module}}}};
\node[blocksmallev, fill = blue!50, left = 0.35cm of segmen, font = \normalsize] (trigger) {{\shortstack{\textbf{LR }\\ \textbf{ Image}}}};
\node[blocksmallev, fill = blue!50, right = 0.55cm of feature, font = \normalsize] (class) {{\shortstack{\textbf{Classification }\\ \textbf{ Module}}}};
\node[blocksmallev, fill = blue!50, right = 0.55cm of class, font = \normalsize] (recon) {{\shortstack{\textbf{Reconstruction }\\ \textbf{ of each}}}};
\node[blocksmallev, fill = blue!50, right = 0.55cm of recon, font = \normalsize] (aggre) {{\shortstack{\textbf{Aggregation }\\ \textbf{ of each}}}};
\node[blocksmallev, fill = blue!50, right = 0.55cm of aggre, font = \normalsize] (sr) {{\shortstack{\textbf{SR IMAGE }\\ \textbf{ of each}}}};
\end{tikzpicture}
\end{document}
答案1
所给链接中显示的图像重建:
\documentclass[border=3.141592]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
calc,
positioning,
shapes.arrows}
\begin{document}
\begin{tikzpicture}[
node distance = 17mm,
arr/.style = {-Stealth},
arv/.style = {-, ultra thick, dotted, shorten >=1mm, shorten <=2mm},
box/.style = {draw, semithick, fill=#1,
minimum width=5em, minimum height=5.1\baselineskip,
outer sep=0pt, align=center},
fe/.style = {draw, semithick, fill=teal!30,
outer sep=0pt, font=\linespread{0.84}\selectfont,
align=center},
lbl/.style = {auto, align=center,
font=\footnotesize\linespread{0.84}\selectfont,
name=#1},
SA/.style = {single arrow, draw, semithick,
single arrow head extend=2mm,
minimum height=7mm, minimum width=7mm,
outer sep=0pt},
every edge/.style = {draw, -Stealth},
]
\node (n1) [fe, fill=none] {LR\\image};
\node (sa1) [SA, right=0pt of n1] {};
\node (n2) [box=yellow!50, right=0pt of sa1]
{Segmentation\\ module};
%
\node (n3a) [fe, below right=0pt and 12mm of n2.north east]
{Feature\\ extraction};
\node (n3b) [fe, above right=0pt and 12mm of n2.south east]
{Feature\\ extraction};
%
\node (n4) [box=cyan!30, right=of n2 -| n3a.east]
{Classification\\ Module};
\node (n5) [box = red!50, right = of n4]
{Reconstruction\\ of each patch\\ using the best\\ models};
\node (sa2) [SA, right=0pt of n5] {};
\node (n6) [box=yellow!50, right = 0pt of sa2]
{Aggregation\\ Module};
\node (sa3) [SA, right=0pt of n6] {};
\node (n7) [fe, fill=none, right = 0pt of sa3]
{SR\\ image};
\draw (n3a -| n2.east) edge node[lbl=pa] {Patch-1} (n3a)
(n3b -| n2.east) edge node[lbl=pb] {Patch-n} (n3b)
(n3a) edge node[lbl=fa] {Features} (n3a -| n4.west)
(n3b) edge node[lbl=fb] {Features} (n3b -| n4.west)
(n3a -| n4.east)
edge node[lbl=bma] {Best model\\ for Patch-1} (n3a -| n5.west)
(n3b -| n4.east)
edge node[lbl=bmb] {Best model\\ for Patch-n} (n3b -| n5.west)
;
\draw (pa) edge [arv] (pb)
(fa) edge [arv] (fb)
(bma) edge [arv] (bmb)
;
\end{tikzpicture}
\end{document}
答案2
作为起点,我给你一个提示,告诉你如何从一个节点画出这两个箭头。
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{shapes,arrows.meta,decorations, positioning, arrows.meta, calc, shapes.geometric}
\begin{document}
\begin{tikzpicture}[node distance=2cm,
block/.style={draw, fill=blue!15, rectangle, minimum height=1.7em, minimum width=2em},
blockev/.style={draw, fill=blue!15, rectangle, minimum height=1.8cm, minimum width=1.8cm},
blocksmallev/.style={draw, fill=blue!15, rectangle, minimum height=1.8cm, minimum width=2.5cm},
input/.style={coordinate},
arr/.style = {-Stealth},]
\node[blocksmallev,text width=2.5cm,align=center] (segmen) {\textbf{Segmentation Module}};
\node[blockev,right= of segmen] (feature) {\textbf{Feature extraction}};
\def\shft{5}
\draw [arr] ([yshift=\shft mm]segmen.east) -- ([yshift=\shft mm]feature.west) node[above,midway] {Patch-1};
\draw [arr] ([yshift=-\shft mm]segmen.east) -- ([yshift=-\shft mm]feature.west) node[above,midway](patchn) {Patch-n};
\node[above=-1mm of patchn]{\vdots};
\end{tikzpicture}
\end{document}
我使用了你在代码中所做的,即使特征提取在草图中的两个框中。
您可以随意调整shft
以腾出更多空间。
现在,您的整个设计还有一些工作要做,您可能需要对其进行更多的组织。您可以在 TeX-SE 上找到许多类似的设计,它们可能会给您带来启发。
编辑:如何连接两个区块
这里你必须使用锚点。我必须定义另一种类型的块,命名为smallblock
并将上面的块放置在右侧segmen.north east
,同时将其附加到north west
锚点。这样上面的线就对齐了。下面的也一样,但位于南边。
然后,为了画箭头(并严格水平绘制),我必须让它们从东侧的交叉口开始段以及水平位置特征1。这个点坐标写成(segmen.east|-feature1)
。那么它指向特征1。
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{shapes,arrows.meta,decorations, positioning, arrows.meta, calc, shapes.geometric}
\begin{document}
\begin{tikzpicture}[node distance=2cm,
block/.style={draw, fill=blue!15, rectangle, minimum height=1.7em, minimum width=2em},
smallblock/.style={draw, fill=olive!15, rectangle, minimum height=7.5mm, minimum width=2em},
blockev/.style={draw, fill=blue!15, rectangle, minimum height=1.8cm, minimum width=1.8cm},
blocksmallev/.style={draw, fill=blue!15, rectangle, minimum height=1.8cm, minimum width=2.5cm},
input/.style={coordinate},
arr/.style = {-Stealth},]
\node[blocksmallev,text width=2.5cm,align=center] (segmen) {\textbf{Segmentation Module}};
\node[smallblock,right= of segmen.north east,anchor=north west] (feature1) {\textbf{Feature extraction}};
\node[smallblock,right= of segmen.south east,anchor=south west] (feature2) {\textbf{Feature extraction}};
\def\shft{5}
\draw [arr] (segmen.east|-feature1) -- (feature1) node[above,midway] {Patch-1};
\draw [arr] (segmen.east|-feature2) -- (feature2) node[above,midway](patchn) {Patch-n};
\node[above=-1mm of patchn]{\vdots};
\end{tikzpicture}
\end{document}