I want to highlight part of an image in beamer by drawing a box around it and setting the rest of the image to a dim setting. I do not know how to decrease the brightness of the rest of the picture. Below is my partial attempt, which almost does the job.
But I am unable to decrease the brightness of the remaining picture outside the small red rectangle at the left bottom. Any help would be greatly appreciated.
\documentclass{beamer}
\usetheme{Copenhagen}
\usecolortheme{whale}
\useinnertheme{rounded}
\usepackage{tikz}
\newcounter{boxes}
\newcommand\ordbox[2]{%
\stepcounter{boxes}
\tikz[remember picture,overlay]{
\node[rectangle,rounded corners,line width=2pt,draw=red,fill=pink,text height=10pt,text depth=3pt,align=left,draw opacity = 0.75, fill opacity=.75,text opacity=1] (box-\theboxes) at #2 {#1};}
}
\newcommand\tikzmark[1]{%
\tikz[remember picture,overlay] \node (#1) {};}
\begin{document}
\begin{frame}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] at (0,0) {\includegraphics[scale=0.2]{../images/H1D_level_5.pdf}};
\end{tikzpicture}
\end{frame}
\begin{frame}
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] at (0,0) {\includegraphics[scale=0.2]{../images/H1D_level_5.pdf}};
\draw[red,ultra thick] (0,0) rectangle (0.5,0.5);
\end{tikzpicture}
\end{frame}
\end{document}
The code above produces the outputs below.
Best Answer
If you name the node in the second slide you can use a
fill=<color>
withfill opacity=<num>
. By naming the node we can easily access the coordinates of the vertices so that we can traverse the region we want to fill:Using a modified version showing those two images side by side to see the effect:
Notes:
0.5\pgflinewidth
. So if you notice that your beamer image shifts from slide to slide, you will need to apply this shift as well.Code:
Code:
Modified to generate the image above.