Skip to content

Instantly share code, notes, and snippets.

@jikkenyametatta
Created June 27, 2015 10:24
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 jikkenyametatta/a89b3f29fc41189ba270 to your computer and use it in GitHub Desktop.
Save jikkenyametatta/a89b3f29fc41189ba270 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
import os
import cv2
import numpy as np
from numpy.random import *
wi = 64
he = 64
def gen():
image = np.random.rand(wi, he)*155+100
image = cv2.GaussianBlur(image,(25,25),-1)
for n in range(20):
cx = random_integers(wi)
cy = random_integers(he)
cv2.circle(image, (cx,cy) , 1, (0,0,0), -1)
return image
def ccc(image, length):
cx = wi/2 + random_integers(-5,5)
cy = he/2 + random_integers(-5,5)
lx = cx + random_integers(-length, length)
ly = cy + random_integers(-length, length)
cv2.line(image,(cx+lx,cy+ly), (cx-lx,cy-ly),(0,0,0))
return image
def ooo(image, radius):
cx = wi/2 + random_integers(-5,5)
cy = he/2 + random_integers(-5,5)
cv2.circle(image, (cx,cy) , radius, (0,0,0))
return image
if __name__ == "__main__":
#os.mkdir(".\\n")
#os.mkdir(".\\c")
#os.mkdir(".\\o")
for i in range(10):
cv2.imwrite("n\\{0:04d}.png".format(i), gen())
cv2.imwrite("c\\{0:04d}.png".format(i), ccc(gen(),90))
cv2.imwrite("o\\{0:04d}.png".format(i), ooo(gen(),4))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment