#!/usr/bin/env python from numpy import * from PIL import Image n = 60 #square size N = 6 #twice number of columns M = 3 #twice number of rows unit = zeros((2*n,2*n)); unit[:n,:n] = 255; unit[n+1:,n+1:] = 255 arr = tile(unit,(M,N)).astype(uint8) Image.fromarray(arr).save('checkerboard.png')