# TikZ: Blurring Effect

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?

• There are some techniques for blurring text here: Blur the text so it's not readable. I'm not sure if this is the kind of effect that would be useful here, though. – Alan Munn Mar 30 '12 at 12:34
• I would suggest just using a lighter colour for the irrelevant columns – Jake Mar 30 '12 at 12:36
• Could you add a picture of your current output, just to give people a better idea of what you're talking about? – doncherry Mar 30 '12 at 13:15

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:

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:

• You can use column 12/.style={opacity=0.1} added to the matrix key list to alter, say, the opacity of the last column – percusse Mar 30 '12 at 12:49
• @percusse: I tried that, but it doesn't seem to work. I tried all kinds of combinations, but setting all nodes to some opacity and then then override the last one doesn't work. That is, we don't want to change one column, we want to change all except one. – Roelof Spijker Mar 30 '12 at 12:52
• Ah, you used nodes={}, and I thought you are using only opacity=0.1. Probably that's why. For example I tried adding ,opacity=0.1,column 12/.style={opacity=0.5} and seems to work. – percusse Mar 30 '12 at 12:54
• Yeah, using opacity directly also changes the opacity of other elements (such as the lines). I tried any kind of combination with nodes, every node, etc. They all appear to occur either after column 12/.style does, or there is some kind of aggregating issue at play. I'll experiment some with transparency groups. – Roelof Spijker Mar 30 '12 at 12:56
• You have to use column 12/.style={nodes={opacity=0.1}} to change the opacity. By the way, it probably makes more sense to just change the text colour to gray instead of using transparency. – Jake Mar 30 '12 at 12:58