小编Bri*_*rit的帖子

如何创建仅在图像中显示黑色的白色蒙版?

我正在尝试获取专辑封面的轮廓,但边缘检测器(Canny、Laplace)拾取了太多噪音。我不完全理解图像遮罩的工作原理,并且想在图像上放置白色遮罩,这样我只能看到黑色像素

我应用了 GaussianBlur 5x5 并将图像转换为 hsv 值。我有一系列黑色值,我已将其过滤掉。

# imported image and processing (shorthand here)
image = cv2.imread(args["image"])
blur = cv2.GaussianBlur(image, (5,5), 0)
blur_hsv = cv2.cvtColor(blur, cv2.COLOR_BGR2HSV)

# set regions of color 
boundaries = [
    # black 
    ([0,0,0],[180, 255, 40])

    #pink
    #([151, 80, 50], [174, 255, 255])   
]

# loop over the boundaries
for (lower, upper) in boundaries:
    # create NumPy arrays from the boundaries
    lower = np.array(lower, dtype = "uint8")
    upper = np.array(upper, dtype = "uint8")

    # find the colors …
Run Code Online (Sandbox Code Playgroud)

python opencv

7
推荐指数
1
解决办法
8010
查看次数

标签 统计

opencv ×1

python ×1