im = pil2array(im)
m = np.amax(im)
im = gaussian_filter(im.astype("f")/m, 0.5)
im += np.random.normal(mean, sigma, im.shape)
flipped = np.ceil(density/2 * im.size)
coords = [np.random.randint(0, i - 1, int(flipped)) for i in im.shape]
im[coords] = 255
coords = [np.random.randint(0, i - 1, int(flipped)) for i in im.shape]
im[coords] = 0
return array2pil(np.clip(im * m, 0, 255).astype("uint8"))
def distort_line(im, distort=3.0, sigma=10.0):