Where do pixels go when an offset crosses the right edge?
offset shifts an image cyclically, wrapping pixels from one edge to the opposite edge.
Pixel experiment and interpretation
Rolling the last sample into the first cell suits periodic textures. Ordinary scene augmentation usually needs background fill to avoid an object reappearing across the frame.
from PIL import Image, ImageChops
def row(values):
return Image.frombytes('L', (len(values), 1), bytes(values))
list(ImageChops.offset(row([1,2,3,4]),1,0).tobytes())Result [4, 1, 2, 3]
中文
平移后越过右边界的像素会去哪里?
offset 以循环方式平移图像,越过一侧的像素从另一侧重新出现。
像素实验与适用边界
把最后一个样本滚回第一格适合周期纹理。自然场景的平移增强通常要补背景,避免边缘对象从对侧钻出来。
from PIL import Image, ImageChops
def row(values):
return Image.frombytes('L', (len(values), 1), bytes(values))
list(ImageChops.offset(row([1,2,3,4]),1,0).tobytes())结果 [4, 1, 2, 3]