How can I soften just the edges of this image

后端 未结 2 2023
陌清茗
陌清茗 2021-01-27 19:46

I am using python and opencv to cut an image using a mask. The mask itself is quite jagged and so the resulting image becomes a bit jagged around the edges like below

Ja

2条回答
  •  面向向阳花
    2021-01-27 20:10

    These are some effects you can do with the PIL image library:

    from PIL import Image, ImageFilter
    im_1 = Image.open("/constr/pics1/russian_doll.png") 
    im_2 = im_1.filter(ImageFilter.BLUR) 
    im_3 = im_1.filter(ImageFilter.CONTOUR) 
    im_4 = im_1.filter(ImageFilter.DETAIL) 
    im_5 = im_1.filter(ImageFilter.EDGE_ENHANCE) 
    im_6 = im_1.filter(ImageFilter.EDGE_ENHANCE_MORE) 
    im_7 = im_1.filter(ImageFilter.EMBOSS) 
    im_8 = im_1.filter(ImageFilter.FIND_EDGES) 
    im_9 = im_1.filter(ImageFilter.SMOOTH) 
    im_10 = im_1.filter(ImageFilter.SMOOTH_MORE) 
    im_11 = im_1.filter(ImageFilter.SHARPEN)
    
    # now save the images
    
    im_2.save("/constr/picsx/russian_dol_BLUR.png") 
    im_3.save("/constr/picsx/russian_doll_CONTOUR.png") 
    im_4.save("/constr/picsx/russian_doll_DETAIL.png") 
    im_5.save("/constr/picsx/russian_doll_EDGE_ENHANCE.png") 
    im_6.save("/constr/picsx/russian_doll_EDGE_ENHANCE_MORE.png") 
    im_7.save("/constr/picsx/russian_doll_EMBOSS.png") 
    im_8.save("/constr/picsx/russian_doll_FIND_EDGES.png") 
    im_9.save("/constr/picsx/russian_doll_SMOOTH.png") 
    im_10.save("/constr/picsx/russian_doll_SMOOTH_MORE.png") 
    im_11.save("/constr/picsx/russian_doll_SHARPEN.png")
    

提交回复
热议问题