#23 create tool path

first working version
This commit is contained in:
Ian
2019-02-04 16:41:18 -05:00
parent b6bf4d9291
commit e2bc465bb9
2 changed files with 68 additions and 1 deletions

59
utils/path.py Normal file
View File

@@ -0,0 +1,59 @@
def scanHorizontal(image, rTool):
width = len(image[0])
height = len(image)
for line in range(height):
for column in range(width):
if image[line][column] == 1 and image[line][ column - 1] == 0:
for px in range(2 * rTool):
if image[line - rTool + px][column - rTool] == 0:
image[line - rTool + px][column - rTool] = 2
if image[line][column] == 1 and image[line][ column + 1] == 0:
for px in range(2 * rTool):
if image[line - rTool + px][column + rTool] == 0:
image[line - rTool + px][column + rTool] = 2
return image
def scanVertical(image, rTool):
width = len(image[0])
height = len(image)
for line in range(height):
for column in range(width):
if image[line][column] == 1 and image[line - 1][ column] == 0:
for px in range(2 * rTool):
if image[line - rTool][column - rTool + px] == 0:
image[line - rTool][column - rTool + px] = 2
elif image[line][column] == 1 and image[line + 1][column] == 0:
for px in range(2 * rTool):
if image[line + rTool][column - rTool + px] == 0:
image[line + rTool][column - rTool + px] = 2
return image
def twoRemoving(image, rTool):
rTool -= 1
width = len(image[0])
height = len(image)
for line in range(height):
for column in range(width):
if image[line][column] == 1:
for px in range(2 * rTool + 1):
if image[line - rTool + px][column] == 2:
image[line - rTool + px][column] = 0
if image[line][column - rTool + px] == 2:
image[line][column - rTool + px] = 0
return image