Im running this to fill image bottom starting from some upper pixel with value>0:
def fillDown(im):
h,w=im.shape
for i in range(w):
for j in range(h):
if im[j][i]>0:
for k in range(j,h):
im[k][i]=255
break
This takes far too long on large images, how would you suggest to optimize this?