\newcommand{\pixel}[2][]{
    \pgfmathparse{#2/255*100}
    \pgfmathsetmacro{\temp}{\pgfmathresult}
    \pgfmathparse{(#2<127)*255}
    \node (#1) [
        fill=white!\temp!black,
        text=white!\pgfmathresult!black
    ] {#2};
}

\begin{tikzpicture}
\matrix (lahtokuva) [nodes={draw, font=\scriptsize, minimum size=7mm}]
{
    \pixel{0} & \pixel{255} \\
    \pixel{255} & \pixel{0} \\
    \pixel{255} & \pixel{255} \\
    \pixel{255} & \pixel{0} & \pixel{255} & \pixel{0} & \pixel{255} \\
    \pixel{0} & \pixel{255} & \pixel{255} & \pixel{255} & \pixel{0} \\
};

\matrix (lahtokuva_part) [anchor=north east, nodes={draw, font=\scriptsize, minimum size=7mm}]
at ($(lahtokuva.north east) + (3mm,3mm)$)
{
\pixel[imgv]{255} & \pixel{255} & \pixel{0} \\
\pixel{255} & \pixel{0} & \pixel{255} \\
\pixel{0} & \pixel{255} & \pixel{255} \\
};

\matrix (kerneli) [anchor=north west, matrix of nodes, nodes={draw, font=\scriptsize, minimum size=7mm}]
at ($(lahtokuva.north east) + (1cm,0)$)
{
    |(kernv)| 0.05 & 0.05 & 0.05 \\
    0.05 & 0.60 & 0.05 \\
    0.05 & 0.05 & 0.05 \\
};

\matrix (lasku) [above=0.5cm, matrix of math nodes, nodes={font=\small}]
at (kerneli.north) {
    |(calcv)| 255\cdot0.05 &+& 255\cdot0.05 &+& 0\cdot0.05 &+ \\
    255\cdot0.05 &+& 0\cdot0.60 &+& 255\cdot0.05 &+ \\
    0\cdot0.05 &+& 255\cdot0.05 &+& 255\cdot0.05 &=& |(result)| 76.5 \approx 77 \\
};

\matrix (tuloskuva) [right=5cm, nodes={draw, font=\scriptsize, minimum size=7mm}]
at (lahtokuva.east)
{
    \node{?}; & \node{?};  \\
    \node{?}; & \pixel{77}  \\
    \node{?}; & \pixel{191}  \\
    \node{?}; & \pixel{77} & \pixel{191} & \pixel{77} & \node{?}; \\
    \node{?}; & \node{?}; & \node{?}; & \node{?}; & \node{?}; \\
};

\matrix (tuloskuva_part) [anchor=north east, nodes={draw, font=\scriptsize, minimum size=7mm}]
at ($(tuloskuva.north east) + (3mm,3mm)$)
{
    \node{?}; & \node{?}; & \node{?}; \\
    \pixel{191} & \pixel[resultpix]{77} & \node{?}; \\
    \pixel{51} & \pixel{191} & \node{?}; \\
};

\draw [->, thick] ($(imgv.center) + (0,2mm)$) -- ($(calcv.south west) + (4mm,1mm)$);
\draw [->, thick] ($(kernv.center) + (0,2mm)$) -- ($(calcv.south east) + (-3mm,1mm)$);;
\draw [->, thick] ($(result.south east) + (-1mm,1mm)$) -- ($(resultpix.center) + (-1mm,2mm)$);;

\node [below] at (lahtokuva.south) {Lähtökuva ($5\times5$)};
\path let \p1=(lahtokuva.south), \p2=(kerneli) in
node [below] at (\x2,\y1) {Kerneli ($3\times3$)};
\node [below] at (tuloskuva.south) {Tuloskuva ($5\times5$)};

\end{tikzpicture}