If I have two images side by side, how do I include an inset using tikz as shown below:

Thank you very much!

I use three nodes: first node a contains left image, the second b contains the right image and is shifted of 1 cm from first one. Last node c points out the area you want. Right image is repeated a second time to overlap partially the \draw(c.north east) -- (b.north east); and \draw(c.south east) -- (b.south east);.

\documentclass{article}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{mwe}
\begin{document}
\begin{tikzpicture}
\node(a){\includegraphics[width=.4\textwidth]{example-image-a}};
\node(b)[inner sep=0pt,right = 1cm of a] {\phantom{\includegraphics[width=.4\textwidth]{example-image-b}}};
\node(c)[draw,minimum size=2cm, at=(a)]{};
\begin{scope}[thin,blue!40]
\draw(c.north east) -- (b.north east);
\draw(c.south east) -- (b.south east);
\draw(c.north west) -- (b.north west);
\draw(c.south west) -- (b.south west);
\end{scope}
\node [at=(b),inner sep=0pt,right = 1cm of a] {\includegraphics[width=.4\textwidth]{example-image-b}};
\end{tikzpicture}

\end{document}