def swap_quadrants(img):
    'Quarter the image and swap two diagonal quadrant pairs.'
    boxes = quarter_bbox(img)
    regions = [img.crop(box) for box in boxes]
    target = img.copy()
    paste_with_alpha(target, regions[3], (0, 0), 128)
    paste_with_alpha(target, regions[2], (regions[3].size[0], 0), 128)
    paste_with_alpha(target, regions[1], (0, regions[3].size[1]), 128)
    paste_with_alpha(target, regions[0], regions[3].size, 128)
    return target
Quarter the image and swap two diagonal quadrant pairs.
def swap_quadrants(img):
    
    boxes = quarter_bbox(img)
    regions = [img.crop(box) for box in boxes]
    target = img.copy()
    paste_with_alpha(target, regions[3], (0, 0), 128)
    paste_with_alpha(target, regions[2], (regions[3].size[0], 0), 128)
    paste_with_alpha(target, regions[1], (0, regions[3].size[1]), 128)
    paste_with_alpha(target, regions[0], regions[3].size, 128)
    return target