Skip to content

Instantly share code, notes, and snippets.

@TonyMooori
Created June 18, 2017 16:07
Show Gist options
  • Save TonyMooori/58a68a3825dc7769d764ee5192df5ea3 to your computer and use it in GitHub Desktop.
Save TonyMooori/58a68a3825dc7769d764ee5192df5ea3 to your computer and use it in GitHub Desktop.
斜めに黒線が入った錯視画像を作るコード
# 斜めに黒線入った錯視画像作るコード
import cv2
import numpy as np
im = cv2.imread("neri.jpeg")
rate = 0.1
ret = (im*rate+255*(1-rate)).astype(np.uint8)
w,h,c=im.shape
mask = (np.arange(w) / 8)%2 == 0
for i in range(0,h):
ret[mask,i,:]=0
temp = mask[0]
mask[:w-1]=mask[1:]
mask[w-1]=temp
cv2.imshow("a",ret)
cv2.waitKey()
cv2.destroyAllWindows()
cv2.imwrite("b.png",ret)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment