一、遍历访问图片每个像素点,并修改相应的RGB
def access_pixels(image):
print(image.shape)
height = image.shape[0]
width = image.shape[1]
channels = image.shape[2]
print("width: %s height: %s channels: %s"%(width, height, 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
cv2.imshow("Reverse_phase_image",image)
if __name__ =="__main__":
src=cv2.imread('555.png')
cv2.imshow('original_image', src)
t1 = cv2.getTickCount()
access_pixels(src)
t2 = cv2.getTickCount()
time = (t2-t1)/cv2.getTickFrequency()
print("time : %s ms"%(time*1000) )
cv2.waitKey(0)
cv2.destroyAllWindows()
