如何模糊蒙版并平滑其边缘?
How can I blur a mask and smooth its edges?
我想改变这张照片脸颊的颜色。
我得到了一个有锋利边缘的面具
如何模糊蒙版并平滑其边缘?
image
mask
# 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)
试试这个代码来模糊蒙版图像。但我不知道你打算如何将它与你的图像一起使用。
我想改变这张照片脸颊的颜色。 我得到了一个有锋利边缘的面具 如何模糊蒙版并平滑其边缘? image mask
# 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)
试试这个代码来模糊蒙版图像。但我不知道你打算如何将它与你的图像一起使用。