def stop_diff(val):
    """Check whether diffusion should stop. If meet busbar(val=1) or crack(val=-1), stop diffusion
    Parameters
    ----------
    val: int
    Grayscale value of a pixel

    Returns
    -------
    bool
    """
    return val == 1 or val == -1