private int[] getNeighborsFor(AsciiImage img, int x, int y) {

        int[] neighbours = new int[9];

        int current = 0;

        --x;
        --y;

        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
                if (!img.isInsideBounds(x + i, y + j))
                    neighbours[current++] = brightest();
                else
                    neighbours[current++] = getValueOf(img.getPixel(x + i, y + j));
            }
        }

        assert current == 9;

        Arrays.sort(neighbours);

        return neighbours;
    }