Q:

Draw matrix with specific style in TikZ

I'm wondering how could I draw a matrix like that:

I know how to draw a simple matrix:
\documentclass[journal]{IEEEtran}

\usepackage[pdftex]{graphicx}

\usepackage{tikz}
\usetikzlibrary{matrix, calc}

\begin{document}

\begin{tikzpicture}

\matrix (input) [matrix of nodes,
                nodes={rectangle, draw=white, minimum size=.8cm}] at (0,0)
{
|[fill=black]| & |[fill=black!20]|  & |[fill=black!50]|         \\
|[fill=black!50]| & |[fill=black!50]|  & |[fill=black!20]|      \\
|[fill=black!20]| & |[fill=black!20]|  & |[fill=black]|         \\
};
\node [draw,below=8pt] at (input.south) {Sample};

\end{tikzpicture}

\end{document}

But not how to change it to achieve what I want.
Thank you.

A:

One answer using the rotation symetry of the figure : 
\begin{tikzpicture}[thick, scale=.35]
  \draw[densely dotted, gray, shift={(-4.5,-4.5)}] (0,0) grid +(9,9);
  \draw (-4.5,-4.5) rectangle (4.5,4.5);
  \node {x};
  \foreach[count=\i] \a in {0,1,2,3} {
    \begin{scope}[rotate={90*\a}]
      \draw (4.5,3.5) -| ++(-1,-1) -| ++(-1,-1) -| ++(-1,-1) -- ++(-6,0);
      \path let \n1={int(2*\i-1)}, \n2={int(2*\i)} in (3,1) node{\n1} (2,3) node{\n2};
    \end{scope}
  }
\end{tikzpicture}

