# How to Create a Script for Feathering Edges?

**URL:** <https://forum.opencv.org/t/how-to-create-a-script-for-feathering-edges/9293>\
**Category:** Python\
**Tags:** imgproc\
**Created:** [June 25, 2022, 11:26pm UTC](https://forum.opencv.org/t/how-to-create-a-script-for-feathering-edges/9293 "2022-06-25T23:26:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![HEART\_LOCKET](https://avatars.discourse-cdn.com/v4/letter/h/9de0a6/32.png) [@HEART\_LOCKET](https://forum.opencv.org/u/HEART_LOCKET)\
**Post date:** [June 25, 2022, 11:26pm UTC](https://forum.opencv.org/t/how-to-create-a-script-for-feathering-edges/9293/1 "2022-06-25T23:26:39Z")

</div>

I have been following examples for a script that I can use to feather (blur) edges of masked images. In just about every example I get to a point where they use an operation like mask==np.array[(255,255,255]) to replace the target image with the sections from the masked image. However, whenever I run these scripts I receive a deprecation warning and no result:  
/usr/local/lib/python3.7/dist-packages/ipykernel\_launcher.py:13: DeprecationWarning: elementwise comparison failed; this will raise an error in the future.  
del sys.path[0]

I’m guessing this is using a deprecated numpy functionality and I’m not sure how to move forward. I’ve put my full code below. I am a beginner and my ultimate goal is to create a solid system for batch feathering from masked frames, so if anyone has further suggestions or reading materials on this topic let me know!

Cheers!

```auto
image = cv2.imread('/content/drive/image.png')

mask1 = np.zeros(image.shape[:2], dtype="uint8")

cv2.circle(mask1, (500, 500), 500, 255, 30)

mask2 = np.zeros(image.shape[:2], dtype="uint8")

cv2.circle(mask2, (500, 500), 500, (255,255,255), -1)

masked = cv2.bitwise_and(image, image, mask=mask1)

masked2 = cv2.bitwise_and(image, image, mask=mask2)

feathered = cv2.GaussianBlur(masked, (21,21), 50)

output = np.where(mask2==np.array([255,255,255]), masked2, feathered)

```

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [June 26, 2022, 12:09am UTC](https://forum.opencv.org/t/how-to-create-a-script-for-feathering-edges/9293/2 "2022-06-26T00:09:07Z")

</div>

related: [python - Best way to feather edges in opencv? - Stack Overflow](https://stackoverflow.com/questions/72757891/best-way-to-feather-edges-in-opencv)
