I want to change the color of the cheeks of this photo. I got a mask with sharp edges How can I blur a mask and smooth its edges? image mask
Asked
Active
Viewed 991 times
-2
-
1Thanks for posting this question! Can you post the code you have so far and explain how you are stuck? – Cam Apr 15 '22 at 15:11
-
ok this code https://stackoverflow.com/questions/71874524/how-can-i-change-the-color-of-a-part-of-the-image-without-losing-the-texture-of problem: I want to change the color of the cheeks of this photo. I got a mask with sharp edges How can I blur a mask and smooth its edges? – zeinab.mostafavi Apr 15 '22 at 15:21
-
1May I suggest that you do some image processing tutorials? For example, if you work through some of these, you'll soon get the hang of things > https://scikit-image.org/docs/stable/auto_examples/ – Matt Hall Apr 15 '22 at 15:25
-
See how I blur the mask and stretch it to blend the edges of the lips at https://stackoverflow.com/questions/71860084/how-can-i-change-the-color-of-the-lip-that-got-its-landmarks-without-disturbing/71864126#71864126 – fmw42 Apr 15 '22 at 15:31
-
Welcome to Stack Overflow. Please read the information guides in the **help center** (https://stackoverflow.com/help), in particular, "How to Ask A Good Question" (https://stackoverflow.com/help/how-to-ask) and "How to create a Minimal, Reproducible Example" (https://stackoverflow.com/help/minimal-reproducible-example). – fmw42 Apr 15 '22 at 15:32
-
Similar questions on this topic of changing make-up have been asked several times recently. Is this some school project? – fmw42 Apr 15 '22 at 15:33
-
yes project of my university – zeinab.mostafavi Apr 15 '22 at 15:37
1 Answers
1
# 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)
Try this code to blur the mask image. But I don't know how you're going to use it with your image.

debugger
- 1,442
- 1
- 9
- 14
-
-
You can use cv2.circle( ) method for detection the specified area and make it blur. and you may use np.where() method to select the pixels where you want blurred values and then replace them. – debugger Apr 15 '22 at 16:16