Skip to content

Instantly share code, notes, and snippets.

@inaniwa3
Last active April 29, 2020 05:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inaniwa3/87074eed239ded1b2113d73eb15accca to your computer and use it in GitHub Desktop.
Save inaniwa3/87074eed239ded1b2113d73eb15accca to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# ref.
# 伝説の超古代文明「ムー」
# http://www.nazotoki.com/mu.html
import cv2
import numpy as np
kernel7 = np.array([
[0, 0, 1, 1, 1, 0, 0],
[0, 1, 1, 1, 1, 1, 0],
[1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1],
[1, 1, 1, 1, 1, 1, 1],
[0, 1, 1, 1, 1, 1, 0],
[0, 0, 1, 1, 1, 0, 0],
], np.uint8)
kernel5 = np.array([
[0, 1, 1, 1, 0],
[1, 1, 1, 1, 1],
[1, 1, 1, 1, 1],
[1, 1, 1, 1, 1],
[0, 1, 1, 1, 0],
], np.uint8)
mu = cv2.imread('mu.png', cv2.IMREAD_GRAYSCALE)
pacific = cv2.imread('pacific.png', cv2.IMREAD_COLOR)
dilation = cv2.dilate(mu, kernel7, iterations = 6)
gradient = cv2.morphologyEx(dilation, cv2.MORPH_GRADIENT, kernel5)
idx = gradient[...] == 255
pacific[idx] = [0, 0, 255]
cv2.imwrite('eez.png', pacific)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment