答案1
在将边界框设置为图片大小的范围内添加云注释。这样,云就不会占用额外空间。(实际上,在这个例子中不需要范围,但有了它,图形可以在范围之后继续,而不会影响云部分。)
\documentclass{beamer}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{calc,shapes}
\begin{document}
\begin{frame}
\frametitle{Test}
\centering
\begin{tikzpicture}
\node[inner sep=0pt](Img){\includegraphics[width=0.7\linewidth]{example-image}};
\draw<2->[line width=2pt,red](Img.north west) rectangle +(4,-2.5);
\draw<3->[line width=2pt,black!20!green](Img.south west) rectangle ($(Img.south east) + (0,3.1)$);
\onslide<4->{%
\begin{scope}
\useasboundingbox(Img.south west)--(Img.north east);
\node[draw,cloud,anchor=south east,aspect=3,fill=blue,text=white] (Cloud) at ($(Img.north east)+(-0.5,0.5)$){2 variables};
\draw[-latex,very thick] (Cloud.south west) to[bend right] ($(Img.center)+(2,1)$);
\end{scope}}
\end{tikzpicture}
\end{frame}
\end{document}