我想在 python 中镜像一个图像,但是发生了这个错误
Exception has occurred: IndexError
index -751 is out of bounds for axis 1 with size 750
File "D:\PART 1\Miror.py", line 20, in <module>
d=img.item(i,mn,0)
这是我的代码
img = cv2.imread('D:\\PART 1\\gwk.jpg')
tinggi = img.shape[0]
lebar = img.shape[1]
brightness = 100
nm=int(tinggi-1)
mn=int(lebar-1)
lebarBaru= int(lebar/2)
tinggiBaru= int(tinggi/2)
for i in np.arange(tinggiBaru):
for j in np.arange(lebarBaru):
a=img.item(i,j,0)
b=img.item(i,j,1)
c=img.item(i,j,2)
d=img.item(i,mn,0)
e=img.item(i,mn,1)
f=img.item(i,mn,2)
img.itemset((i,j,0),d)
img.itemset((i,j,1),e)
img.itemset((i,j,2),f)
img.itemset((i,mn,0),a)
img.itemset((i,mn,1),b)
img.itemset((i,mn,2),c)
mn-=1
我想在 python 中镜像图像而不使用 OpenCV 函数来镜像图像
