1.基本操作
import numpy as np
import cv2 as cv
image = cv.imread('/Users/youkechaung/Desktop/算法/数据分析/AI/day02/day02/data/forest.jpg')
# print(image)
# print(image.shape)
#(397, 600, 3) 高 宽
# cv.imshow('Original',image)
h,w = image.shape[:2] #取高和宽
l,t = int(w/4),int(h/4)
r,b = int(w*3/4),int(h*3/4) #小图的左顶右底
cropped = image[t:b,l:r]
cv.imshow('Cropped',cropped)
blue= np.zeros_like(cropped)
blue[...,0] = cropped[...,0]
cv.imshow('Blue',blue)
green= np.zeros_like(cropped)
green[...,1] = cropped[