python - 如何在 Python 中不使用 JES 函数水平翻转图像
问题描述
我正在尝试水平翻转图像,该图像作为参数传递给我的函数。我不能使用 JES 功能。我有下面的代码。我究竟做错了什么?
height = len(image)
width = len(image[0])
for row in range(height):
for col in range(width//2):
srcPixel = image[row][col]
tgtPixel = image[width - col - 1][row]
tmpPixel = srcPixel
srcPixel = tgtPixel
tgtPixel = tmpPixel
return True
解决方案
height = len(image)
width = len(image[0])
for row in range(height):
for col in range(width//2):
tmpPixel = image[row][col]
image[row][col] = image[row][width - col - 1]
image[row][width - col - 1] = tmpPixel
return True
tmpPixel 不像 C 那样保留数据的地址。