这篇文章给大家介绍Python中怎么利用OpenCV实现水彩效果,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。
要求:
油画效果需要使用OpenCV Contrib模块,而其他模块可以使用OpenCV的标准发行版执行。除此之外,点画艺术还需要Sklearn和Scipy。
pip install opencv-contrib-python==4.3.0.36
pip install scikit-learn
pip install scipy
油画效果
它包括在内cv2.xphoto(),还具有其他一些很酷的功能,例如图像修复,白平衡,图像去噪等。
import cv2
img = cv2.imread('img.jpg')
res = cv2.xphoto.oilPainting(img, 7, 1)
水彩效果
像油画效果一样,水彩效果也可以用单行代码完成,但不包括导入和图像读取。
cv2.stylization()。
import cv2
img = cv2.imread('img.jpg')
res = cv2.stylization(img, sigma_s=60, sigma_r=0.6)
# sigma_s controls the size of the neighborhood. Range 1 - 200
# sigma_r controls the how dissimilar colors within the neighborhood will be averaged. A larger sigma_r results in large regions of constant color. Range 0 - 1
关于Python中怎么利用OpenCV实现水彩效果就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。