import copy


def rearange(im):
    """
    rearange k space to set 0,0 to the center of the image
    """
    h,w = int(im.shape[0]/2), int(im.shape[1]/2)
    cop = copy.deepcopy(im)
    im[:h, :w] = cop[h:, w:]
    im[h:, w:] = cop[:h, :w]
    im[h:, :w] = cop[:h, w:]
    im[:h, w:] = cop[h:, :w]
    return im