Beamer – Highlight a Region of an Image with Rectangle Overlay

beamergraphicsoverlaysrounded-cornerstikz-pgf

I have a slide with a figure in it. I want to draw a rounded corner rectangle overtop part of a figure to highlight that section. Bonus points if you can draw two rounded rectangles as overlays that appear one at a time.

alt text

\documentclass{beamer}
\usepackage[T1]{fontenc}

\begin{document}

\begin{frame}
    \frametitle{ESR1} 

    \begin{center}
        Functional analysis
    \end{center}

    \begin{center}
        \includegraphics[width=1\textheight]{some_image.jpg}
    \end{center}
\end{frame}
\end{document}

(Note: I removed most of the unnecessary code in the example code, so the theme in the picture doesn't match with the default one in the example code anymore. –Caramdir)

Best Answer

You can include the picture into a TikZ node and then draw some rectangles over it. For example,

\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage{tikz}

\begin{document}

\begin{frame}
    \frametitle{ESR1} 

    \begin{center}
        Functional analysis
    \end{center}

    \begin{center}
        \begin{tikzpicture}
            \node[anchor=south west,inner sep=0] at (0,0) {\includegraphics[width=1\textheight]{some_image.jpg}};
            \draw<1>[red,ultra thick,rounded corners] (1.6,1) rectangle (\textheight-1cm,5);
            \draw<2>[red,ultra thick,rounded corners] (5.7,4.1) rectangle (7.5,4.9);
        \end{tikzpicture}
    \end{center}
\end{frame}
\end{document}

with a picture from Wikipedia as some_image.jpg gives the two slides

example

Note the \node[anchor=south west,inner sep=0] at (0,0) {\includegraphics{...}}; line. This adds the picture so that the lower left corner is at the origin of the TikZ coordinate system. Section 14.6 “Rounding Corners” of the TikZ manual (v2.10) tells you how you can change the corner rounding.

Btw, do you really mean width=1\textheight?