์ฝ๋ํ ๋ง
import numpy as np
import cv2
# ์ด๋ฏธ์ง๋ฅผ ๋ถ๋ฌ์จ๋ค.
map_img = cv2.imread('map.png', 0)
# ์ด๋ฏธ์ง๋ฅผ ์ํ๋ ๊ทธ๋ฆฌ๋ ์ฌ์ด์ฆ๋ก ์ค์ธ๋ค(40 × 40)
map_img = cv2.resize(map_img, dsize=(40, 40))
# numpy ๋ฐฐ์ด์ ๋ง๋ค๊ณ ,
width, height = map_img.shape
map = np.zeros((width, height), np.uint8)
# ๊ฒ์ ์ ํฝ์
์ 0, ๋๋จธ์ง ํฝ์
์ 1๋ก ์ฑ์ ๋ค.
for x in range(height):
for y in range(width):
if map_img[x][y] > 0:
map[x][y] = 1
else:
map[x][y] = 0
# hhlab.tistory.com
'๐ป > ๋ฉํฐ๋ฏธ๋์ด' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[์์์ฒ๋ฆฌ] ์ค๊ฐ๊ฐ ํํฐ, ์ค๊ณฝ์ ๊ฒ์ถ (0) | 2020.10.18 |
---|---|
[์์์ฒ๋ฆฌ] ๋ฐ์ค ํํฐ, ๊ฐ์ฐ์์ ํํฐ (1) | 2020.10.18 |
[์์์ฒ๋ฆฌ] ๋นํธ ํ๋ฉด ๋ถํธํ, ํ์คํ ๊ทธ๋จ (0) | 2020.10.11 |
[์์์ฒ๋ฆฌ] ๊ธฐํ ๋ณํ, ์ญ๋ฐฉํฅ ๋งคํ (2) | 2020.10.11 |
[์์์ฒ๋ฆฌ] ๋์งํธ ์ด๋ฏธ์ง (0) | 2020.10.11 |