src=cv.imread('./data/coins.jpg')
access_pixels(src)
def access_pixels(image):
print('shape',image.shape)
print('高度',image.shape[0])
print('宽度', image.shape[1])
print('通道数', image.shape[2])
print('宽度:%s,高度:%s'%(image.shape[0],image.shape[1]))
##相当于取反 例如白的变成黑的,黑的变成白的,
for row in range(image.shape[0]):
for col in range(image.shape[1]):
for c in range(image.shape[2]):
pv=image[row,col,c]
image[row,col,c]=255-pv #相当于取反 例如白的变成黑的,黑的变成白的,
cv.imshow('pixels_demo',image)