Created
June 12, 2020 09:18
-
-
Save trongan93/9b365e8e663e38607832a957130ec5a2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cutting(x, y): | |
area_study = np.arange(3*80*80).reshape(3, 80, 80) | |
for i in range(80): | |
for j in range(80): | |
area_study[0][i][j] = picture_tensor[0][y+i][x+j] | |
area_study[1][i][j] = picture_tensor[1][y+i][x+j] | |
area_study[2][i][j] = picture_tensor[2][y+i][x+j] | |
area_study = area_study.reshape([-1, 3, 80, 80]) | |
area_study = area_study.transpose([0,2,3,1]) | |
area_study = area_study / 255 | |
sys.stdout.write('\rX:{0} Y:{1} '.format(x, y)) | |
return area_study | |
def not_near(x, y, s, coordinates): | |
result = True | |
for e in coordinates: | |
if x+s > e[0][0] and x-s < e[0][0] and y+s > e[0][1] and y-s < e[0][1]: | |
result = False | |
return result | |
def show_ship(x, y, acc, thickness=5): | |
for i in range(80): | |
for ch in range(3): | |
for th in range(thickness): | |
picture_tensor[ch][y+i][x-th] = -1 | |
for i in range(80): | |
for ch in range(3): | |
for th in range(thickness): | |
picture_tensor[ch][y+i][x+th+80] = -1 | |
for i in range(80): | |
for ch in range(3): | |
for th in range(thickness): | |
picture_tensor[ch][y-th][x+i] = -1 | |
for i in range(80): | |
for ch in range(3): | |
for th in range(thickness): | |
picture_tensor[ch][y+th+80][x+i] = -1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment