[Tex/LaTex] TikZ using relative coordinates to position fill rectangle

graphicstikz-pgf

this is my first time I am using tikz so the question is rather simple.
I am trying to achieve a simple effect of highlighting an element on my image, with tikz.

I used this threads:
highlighting some areas in a picture by making the rest of the picture transparent
Highlighting part of an image

And with their help I have managed to have a code like:

\begin{tikzpicture}
\node[anchor=south west] (image) at (0,0)
{\includegraphics[totalheight=0.580\textheight, angle=90]{img/sioux-out/network1}};

\draw[red,ultra thick] (8,9.5) rectangle (10,11.5);
\fill [draw=none, fill=white, fill opacity=0.8] 
    (0,0) rectangle (8,11.5)
    (8,0) rectangle (10,9.5)
    (10,0) rectangle (16,11.5);
\end{tikzpicture}

It is working quite fine, but I would really like to change some of the coordinates to the relative ones, like:

\fill [draw=none, fill=white, fill opacity=0.8] 
    (image.bottom left) rectangle (8,image.top)
    (8,image.bottom) rectangle (10,9.5)
    (10,image.bottom) rectangle (image.top right);

I tried with north, south, east west but it does not work as expected.
What I expect it to be is something like this:

Example effect

Best Answer

There are predefined anchor names for the node image, therefore you can use:

  • (image.south west) instead of (image.bottom left)
  • (image.north east) instead of (image.top right)

Also coordinates can be specified as intersections of perpendicular lines:

  • (8, 0 |- image.north) instead of (8, image.top)
  • (8, 0 |- image.south) instead of (8, image.bottom)
  • (10, 0 |- image.south)instead of (10, image.bottom)
Related Question