下在我们就通过一段python代码来说明应该怎么样去除这些烦人的东西。
def get_left_start_point(im):
start_point = (0,0)
found = False
w, h = im.size
data = list(im.getdata())
for x in xrange(w):
for y in xrange(h):
if data[ y*w + x ] != white:
found = True
start_point = (x,y)
break
if found:
break
return start_point
def remove_line(im, aim):
w,h = im.size
data = list( im.getdata() )
for x,y in aim:
curr = data[ y * w + x ]
prev = data[ (y-1) * w + x]
next = data[ (y+1) * w + x]
if prev == black and next == black:
continue
if prev == black:
data[ y * w + x ] = white
data[ (y-1) * w + x] = white
elif next == black:
data[ y * w + x ] = white
data[ (y+1) * w + x] = white
else:
data[ y * w + x ] = white
相信用过python的朋友一定很容易看出来这些代码都做了什么,其实就是确定线的首尾两端,能确定两端那接下来要处理不就简单得多了吗,具体的做法还是看代码吗,说起来没有代码清楚。