Skip to content

Instantly share code, notes, and snippets.

@arijitx
Created February 3, 2016 13:25
Show Gist options
  • Save arijitx/19921db62ceac16f1f54 to your computer and use it in GitHub Desktop.
Save arijitx/19921db62ceac16f1f54 to your computer and use it in GitHub Desktop.
import cv2
import numpy as np
import hashlib
def getUImg(sid):
#size can be
m=hashlib.sha256()
m.update(sid)
hsh=m.hexdigest()
npar=np.zeros((8,8,3),np.uint8)
img=np.zeros((256,256,3),np.uint8)
n=0
for i in range(0,8):
for j in range(0,8):
if(n==3):
n=0
npar[i][j][n]=17*int(hsh[(i+1)*(j+1)-1],16)
npar[i][j][(n+1)%3]=255-npar[i][j][n]
n+=1
npar=cv2.resize(npar,(128,128))
imgLU=npar
imgRU=cv2.flip(npar,1)
img[:128,:128]=imgLU
img[:128,128:256]=imgRU
img[128:256,:256]=cv2.flip(img[:128,:256],0)
return img
sid=raw_input('String: ')
img=getUImg(sid)
cv2.imshow('img',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment