opencv图像填充

opencv图像填充_第1张图片

 opencv图像填充_第2张图片

opencv图像填充_第3张图片opencv图像填充_第4张图片 

灰度

import cv2
import numpy as np
import matplotlib.pyplot as plt

h = 50
x_center = 70
y_center = 120
 

img = np.zeros([256,256],'uint8')
draw_0 = cv2.rectangle(img, (x_center-h, y_center-h), (x_center+h, y_center+h), 1, 2)

plt.figure()
plt.imshow(draw_0)

mask = np.zeros([258, 258],np.uint8)
cv2.floodFill(draw_0, mask, (58, 117), 1, cv2.FLOODFILL_FIXED_RANGE)

plt.figure()
plt.imshow(draw_0)

opencv图像填充_第5张图片

 彩色

img = np.zeros([256,256,3],'uint8')
draw_0 = cv2.rectangle(img, (x_center-h, y_center-h), (x_center+h, y_center+h), (255, 0, 0), 2)
cv2.imshow('a',draw_0)

mask = np.zeros([258, 258],np.uint8)
cv2.floodFill(draw_0, mask, (58, 117), (0, 255, 255), cv2.FLOODFILL_FIXED_RANGE)
cv2.imshow('b',draw_0)

opencv图像填充_第6张图片

你可能感兴趣的:(空间艺术Raumkunst,opencv,计算机视觉)