[Tex/LaTex] Transparency/Opacity of figure in a block with uncover in Beamer

beamerblockoverlaystransparency

I am creating a presentation with Beamer, using Berkeley as theme. On one frame I have the columns environment in order to put two blocks side by side. Each block has a header and contains a picture.

I would like to show both blocks on the first slide and then highlight only the first block on the second slide. I achieved this using the \uncover command but, nevertheless, the picture in the second block is still “fully” visible. On the contrary, I would like also the picture to be faded (note: NOT transparent).

In other words, this is what I get: enter image description here
While this is what I would like to get:enter image description here

This is the MWE I am using:

\documentclass[11pt]{beamer}
\usepackage[english]{babel}
\usepackage{fontenc}
\usepackage[latin1]{inputenc}
\mode<presentation>
{
\usetheme{Berkeley}
\setbeamercovered{transparent}
}

%Title
\title[Example]{Example}

%*DOCUMENT*
\begin{document}

%*INTRODUCTION*
\section{Introduction}

%Trees
\subsection[Trees]{Trees}
\begin{frame}
\frametitle{Introduction:\\ Trees}
\begin{columns}[t]
 \begin{column}{0.48\textwidth}
 \uncover<1,2>{
  \begin{block}{Tree1}
   \begin{figure}
    \centering
        \includegraphics[width=\linewidth]{Tree.jpeg}
        \label{fig:a}
   \end{figure}
  \end{block}}      
 \end{column}
 \begin{column}{0.48\textwidth}
 \uncover<1>{
  \begin{block}{Tree2}
   \begin{figure}
    \centering
        \includegraphics[width=\linewidth]{Tree.jpeg}
        \label{fig:b}
   \end{figure}
  \end{block}}
 \end{column}
\end{columns}
\end{frame} 

\end{document}

Best Answer

I am just building on top of @samcarter great answer and making a new command \uncovergraphics for it, for simple reuse (personally I place it in my custom beamer theme):

\newcommand<>{\uncovergraphics}[2][{}]{
    % Taken from: <https://tex.stackexchange.com/a/354033/95423>
    \begin{tikzpicture}
    \node[anchor=south west,inner sep=0] (B) at (4,0)
        {\includegraphics[#1]{#2}};
    \alt#3{}{%
        \fill [draw=none, fill=background, fill opacity=0.9] (B.north west) -- (B.north east) -- (B.south east) -- (B.south west) -- (B.north west) -- cycle;
    }
    \end{tikzpicture}
}

Note: I used the color named background, which is defined in my colortheme, but change it to your needs.

Then I simply use it like I would for \includegraphics:

\uncovergraphics<2->[width=\linewidth]{tree1}

EDIT:

There was this answer already that proposed the same idea, but redefines includegraphics so that it works in any case (e.g after pause command).

Related Question