def scale(kernel):
    """ Scales a 2D array to [0, 255] """
    minimum = min(min(k) for k in kernel)
    maximum = max(max(k) for k in kernel)
    return [[int(255 * (k - minimum) / (maximum - minimum)) for k in row]
            for row in kernel]