def hysteresis(im, weak, strong=255):
    """Transforms weak pixel into strong ones if at least 1 pixel around the one being processed is a strong one 

    Parameters
    ----------
    im 
        input image
    weak
        weak pixel that has intensity value that is not enough to be considered strong ones, but not non-relevant
    strong
        pixel with very high intensity
    
    Returns
    -------
    im
        output result image
    """
    row, col = im.shape  
    
    for i in range(1, row-1):
        for j in range(1, col-1):
            if (im[i,j] == weak):
                if ((im[i+1, j-1] == strong) or (im[i+1, j] == strong) or (im[i+1, j+1] == strong)
                    or (im[i, j-1] == strong) or (im[i, j+1] == strong)
                    or (im[i-1, j-1] == strong) or (im[i-1, j] == strong) or (im[i-1, j+1] == strong)):
                    im[i, j] = strong
                else:     
                   im[i, j] = 0
    return im