data/dtype/size/shape/len
‘’’
import cv2 as cv
import numpy as np
def access_pixes(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 #像素取反
cv.imshow(“pixels_demo”, image)
def create_image():
#多通道修改
‘’’
img = np.zeros([512, 512, 3], np.uint8) #定义一个三维都是0的矩阵
img[:, :, 0] = np.ones([512, 512])*255 #修改第一个通道(blue通道)
cv.imshow(“new image”, img)
#单通道修改
img = np.ones([512, 512, 1], np.uint8) #定义一个一维的单通道矩阵
img = img*127
cv.imshow("new image", img)
'''
m1 = np.ones([3, 3], np.uint8)
m1.fill(122.83)
print(m1)
m2 = m1.resh