如何模糊蒙版并平滑其边缘?



我想改变这张照片脸颊的颜色。我得到了一个边缘锐利的蒙版 我如何模糊蒙版并平滑其边缘?图像面具

# import the necessary packages
import argparse
import cv2
# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", type=str, default="pca8e.png",
    help="path to input image")
args = vars(ap.parse_args())
# load the image, display it to our screen, and initialize a list of
# kernel sizes (so we can evaluate the relationship between kernel
# size and amount of blurring)
image = cv2.imread(args["image"])
cv2.imshow("Original", image)
kernelSizes = [(41,41)]
# loop over the kernel sizes
for (kX, kY) in kernelSizes:
    # apply a "Gaussian" blur to the image
    blurred = cv2.GaussianBlur(image, (kX, kY), 0)
    cv2.imshow("Gaussian ({}, {})".format(kX, kY), blurred)
    cv2.waitKey(0)

试试下面的代码来模糊蒙版图像。但是我不知道你要怎么把它用在你的图片上。

最新更新