Skip to content

Instantly share code, notes, and snippets.

@Gotoryoo
Created November 29, 2016 05:22
Show Gist options
  • Save Gotoryoo/8f7bb3bdf6497e1c16e446525f1b7ac4 to your computer and use it in GitHub Desktop.
Save Gotoryoo/8f7bb3bdf6497e1c16e446525f1b7ac4 to your computer and use it in GitHub Desktop.
"""
Created on Fri May 01 19:17:23 2015
@author: jyoshida-sci
"""
import cv2
import numpy as np
import itertools
height = 440
width = 512
#generating images#################
for i, j in itertools.product(range(4), range(4)):
img = np.ones((height,width,1), np.uint8)*255
msg="{0}-{1}".format(i,j)
location=(100,200)
fontface=cv2.FONT_HERSHEY_PLAIN
fontscale=10.0
color=(0,0,0)#black
cv2.putText(img,msg,location,fontface,fontscale,color)
cv2.imwrite("{0}-{1}.bmp".format(i,j), img)
#joining images####################
bigimg = np.ones((height*4,width*4), np.uint8)*255
for i, j in itertools.product(range(4), range(4)):
sx=i*width
sy=j*height
ex=(i+1)*width
ey=(j+1)*height
filename="{0}-{1}.bmp".format(i,j)
img = cv2.imread(filename,cv2.CV_LOAD_IMAGE_GRAYSCALE)
bigimg[sy:ey,sx:ex] = img.copy()
cv2.imwrite("bigimg.bmp",bigimg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment