def centercrop(pic, size):
    """ Center-crops a picture in a square shape of given size. """
    x = pic.shape[1]/2 - size/2
    y = pic.shape[0]/2 - size/2
    return pic[int(y):int(y+size), int(x):int(x+size)]