import cv2 as cv
import numpy as np
def access_pixels(image):
print(image.shape)
height = image.shape [0]
width = image.shape [1]
channels = image.shape [2]
print("height : %s,width : %s,channels : %s"%(height,width,channels))
for row in range(height):
for col in range (width):
for c in range (channels):
pv = image[row,col,c]
image[row, col, c] = 255-pv
cv.imshow("pixels_demo",image)
import cv2 as cv
img = cv.imread("D:\Personal\picture\ABC.jpg") #blue,green.red
cv.namedWindow("image")
cv.imshow("image",img)
t1 = cv.getTickCount() #获取时间
access_pixels(img)
t2 = cv.getTickCount()
time = (t2-t1)/cv.getTickCount()
print("time:%s ms"%(time*1000)) #花了多长时间 mS
cv.waitKey(0)
#释放窗口
cv.destroyAllWindows()