对NumPy数组(图像)进行切片和赋值操作。
cd ~/opencv
xxxxxxxxxxpython3 03.image_modify.py
注意:选中图片按q可以退出程序!

ximport cv2def modify_image(input_path, output_path):image = cv2.imread(input_path)if image is None:print("Error: Unable to open image file.")returnimage[:50, :50] = [255, 255, 255]if cv2.imwrite(output_path, image):print(f"Image saved to {output_path}")cv2.imshow('Image Preview', cv2.imread(output_path))cv2.waitKey(0)cv2.destroyAllWindows()else:print("Error: Unable to save image file.")modify_image('/home/jetson/opencv/images/yahboom_logo.png', \'/home/jetson/opencv/images/yahboom_logo_modify.png')