我正在研究 python 中的区域增长算法实现。但是当我在输出上运行此代码时,我得到黑色图像,没有错误。在输入图像上使用 CV 阈值函数,对于种子值,我使用鼠标单击将 x,y 值存储在元组中。
def get8n(x, y, shape):
out = []
if y-1 > 0 and x-1 > 0:
out.append( (y-1, x-1) )
if y-1 > 0 :
out.append( (y-1, x))
if y-1 > 0 and x+1 < shape[1]:
out.append( (y-1, x+1))
if x-1 > 0:
out.append( (y, x-1))
if x+1 < shape[1]:
out.append( (y, x+1))
if y+1 < shape[0] and x-1 > 0:
out.append( ( y+1, x-1))
if y+1 < shape[0] :
out.append( (y+1, x))
if …
Run Code Online (Sandbox Code Playgroud)