[Tex/LaTex] TikZ: Blurring Effect

shadowstikz-pgf

As you know, in Burrows-Wheeler Transform the matrix of all the rotations is but conceptual, and what matters is the last column. I wanted to convey this idea in the picture

\documentclass{standalone}
\usepackage{tikz}

\usetikzlibrary{matrix,positioning}

\begin{document}

\begin{tikzpicture}
    \begin{scope}
            \matrix (B) [matrix of nodes, ampersand replacement = \&]{
                {} \&  {} \&  {} \&  {} \&  {} \&  {} \&  {} \&  {} \&  {} \&  {} \&  {BWT} \& {SA} \\
                \hline
                {a} \& {n} \& {k} \& {u} \& {k} \& {l} \& {u} \& {k} \& {s} \& {k} \& {l} \& {9} \\
                {k} \& {l} \& {a} \& {n} \& {k} \& {u} \& {k} \& {l} \& {u} \& {k} \& {s} \& {7} \\
                {k} \& {l} \& {u} \& {k} \& {s} \& {k} \& {l} \& {a} \& {n} \& {k} \& {u} \& {2} \\
                {k} \& {s} \& {k} \& {l} \& {a} \& {n} \& {k} \& {u} \& {k} \& {l} \& {u} \& {5} \\
                {k} \& {u} \& {k} \& {l} \& {u} \& {k} \& {s} \& {k} \& {l} \& {a} \& {n} \& {0} \\
                {l} \& {a} \& {n} \& {k} \& {u} \& {k} \& {l} \& {u} \& {k} \& {s} \& {k} \& {8} \\
                {l} \& {u} \& {k} \& {s} \& {k} \& {l} \& {a} \& {n} \& {k} \& {u} \& {k} \& {3} \\
                {n} \& {k} \& {u} \& {k} \& {l} \& {u} \& {k} \& {s} \& {k} \& {l} \& {a} \& {10} \\
                {s} \& {k} \& {l} \& {a} \& {n} \& {k} \& {u} \& {k} \& {l} \& {u} \& {k} \& {6} \\
                {u} \& {k} \& {l} \& {u} \& {k} \& {s} \& {k} \& {l} \& {a} \& {n} \& {k} \& {1} \\
                {u} \& {k} \& {s} \& {k} \& {l} \& {a} \& {n} \& {k} \& {u} \& {k} \& {l} \& {4} \\
            };
            \filldraw[semitransparent] (B-1-1.north west) rectangle (B-12-10.south east);
    \end{scope}
\end{tikzpicture}

\end{document}

The effect I would like to achieve is to somehow "blur" the contents of the matrix except for the last column. Do I have to play around with postactions in the matrix options? I could have, of course, explicitly set the relevant elements of the matrix with paler colours, so that the overall blurred effect would be achieved, but is there any way to blur entire regions?

Best Answer

The easiest way that I can think of to blur part of the matrix is to lower the opacity of every node in the matrix and then explicitly set the opacity of the nodes in the last column to 1. That could be achieved like this:

\documentclass{standalone}
\usepackage{tikz}

\usetikzlibrary{matrix}

\begin{document}

\begin{tikzpicture}
    \begin{scope}
            \matrix (B) [matrix of nodes, ampersand replacement = \&,nodes={opacity=.5}]{
                {} \&  {} \&  {} \&  {} \&  {} \&  {} \&  {} \&  {} \&  {} \&  {} \&  {BWT} \& {SA} \\
                \hline
                {a} \& {n} \& {k} \& {u} \& {k} \& {l} \& {u} \& {k} \& {s} \& {k} \& {l} \&|[opacity=1]| {9} \\
                {k} \& {l} \& {a} \& {n} \& {k} \& {u} \& {k} \& {l} \& {u} \& {k} \& {s} \&|[opacity=1]| {7} \\
                {k} \& {l} \& {u} \& {k} \& {s} \& {k} \& {l} \& {a} \& {n} \& {k} \& {u} \&|[opacity=1]| {2} \\
                {k} \& {s} \& {k} \& {l} \& {a} \& {n} \& {k} \& {u} \& {k} \& {l} \& {u} \&|[opacity=1]| {5} \\
                {k} \& {u} \& {k} \& {l} \& {u} \& {k} \& {s} \& {k} \& {l} \& {a} \& {n} \&|[opacity=1]| {0} \\
                {l} \& {a} \& {n} \& {k} \& {u} \& {k} \& {l} \& {u} \& {k} \& {s} \& {k} \&|[opacity=1]| {8} \\
                {l} \& {u} \& {k} \& {s} \& {k} \& {l} \& {a} \& {n} \& {k} \& {u} \& {k} \&|[opacity=1]| {3} \\
                {n} \& {k} \& {u} \& {k} \& {l} \& {u} \& {k} \& {s} \& {k} \& {l} \& {a} \&|[opacity=1]| {10} \\
                {s} \& {k} \& {l} \& {a} \& {n} \& {k} \& {u} \& {k} \& {l} \& {u} \& {k} \&|[opacity=1]| {6} \\
                {u} \& {k} \& {l} \& {u} \& {k} \& {s} \& {k} \& {l} \& {a} \& {n} \& {k} \&|[opacity=1]| {1} \\
                {u} \& {k} \& {s} \& {k} \& {l} \& {a} \& {n} \& {k} \& {u} \& {k} \& {l} \&|[opacity=1]| {4} \\
            };
    \end{scope}
\end{tikzpicture}

\end{document}

I removed the positioning library, since that wasn't used anywhere. The result:

blurred matrix

It looks pretty bad (I am guessing due to the conversion to jpg), in the PDF it looks fine.

Edit: After the discussion in the comments, I agree with Jake's suggestion to make the distinction based on color instead of transparency. I only used transparency in the first place because I felt it was closer to a "blurred" look. I won't repeat the entire code here, you can remove the |[opacity=1]| additions in the last column and change the \matrix line to:

\matrix (B) [matrix of nodes, ampersand replacement = \&,nodes={color=gray},column 12/.style={nodes={color=black}},column 11/.style={nodes={color=black}}]{

The result:

blurring with colours