0

它显示 IndexError: index 172 is out of bounds for axis 1 with size 172. 我感谢任何更正或其他应用图像对称性的方法。

import cv2
from PIL import Image, ImageTk

import numpy as np

img1 = cv2.imread("te.png")

X = np.uint8(img1)  #img1.load()


print( len(X),len(X[0]))

for i in range(len(X)):
  stop = False
  nc = len(X[0])
  for j in range(len(X[0])):
    t = X[i,j]
    if (j == nc/2): 
        break
    else :
        while stop is False:
            X[i,j] = X[i,nc]
            X[i,nc] = t
            nc -= 1
            stop = True




img = Image.fromarray(X, 'RGB')

img.show()
4

0 回答 0