ROI(感兴趣区域):
机器视觉、图像处理中,从被处理的图像以方框、圆、椭圆、不规则多边形等方式勾勒出需要处理的区域,称为感兴趣区域,ROI。
import cv2 as cv import numpy as np src = cv.imread("./01.jpg") cv.imshow("03",src) face = src[50:250,100:300] # 选择区域 gray = cv.cvtColor(face,cv.COLOR_BGR2GRAY) #变灰色 backface= cv.cvtColor(gray,cv.COLOR_BAYER_BG2BGR) #还原 src[50:250,100:300] = backface cv.imshow("face",src) cv.waitKey(0) cv.destroyAllWindows()
泛洪填充
def fill_color_demo(image): copyImage = image.copy() h, w = image.shape[:2] mask = np.zeros([h+2, w+2], np.uint8) # +2 是规定 cv.floodFill(copyImage, mask, (30, 30), (0, 255, 255), # floodFill 填充 (100, 100, 100), (50, 50, 50), cv.FLOODFILL_FIXED_RANGE) cv.imshow("fill_color_demo", copyImage)