Entscheidungsmatrizen

Folgender Code fragt Dinge wiederholt ab:

          Surroundings( Image & img, size_t x, size_t y )
            {
#define look( cond, x, y ) ( cond ) ? img.getIntensity( (x), (y) ) != 0 : 0; 

                if ( x < img.width() && y < img.height )
                {
                    In = img.getIntensity( x, y );

                    if ( x > 0 )
                    {
                        TopLeft = look( y > 0, x - 1, y-1 );
                        Left = img.getIntensity( x - 1, y ) != 0;
                        BottomLeft = look( y + 1 < img.height(), x - 1, y + 1 );
                    }

                    if ( x+1 < img.width() )
                    {
                        TopRight = look( y > 0, x + 1, y - 1 );
                        Right = img.getIntensity( x +1, y ) != 0;
                        BottomRight = look( y + 1 < img.height(), x + 1, y + 1 );
                    }

                    Top = look( y > 0, x, y - 1 );
                    Bottom = look( y + 1 < img.height(), x, y + 1 );
                }
            }

Möglicherweise lässt sich sowas im 2D-Fall auch als Tabelle abbilden:

                matrix
                {
                setBottomRight := BottomRight = look( y + 1 < img.height(), x + 1, y + 1 );
                setBottom := Bottom = look( y + 1 < img.height(), x, y + 1 );

                                          x > 0,   x < width(),  x + 1 < width()

                    y > 0
                    y < height           Left = img.GetIntensity()            in = getIntensity()
                    y + 1 < height         setBottomRight()    setBottom() 
                }

Hier könnte man dann überlegen, ob das auch Tabelle optisch hinterlegt werden kann (| wie im Wiki).

Wie sieht das ganze bei drei abhängigen Variablen aus?