这篇文章主要为大家详细介绍了使用OpenCV怎么将彩色照片转换成素描卡通照片,文中示例代码介绍的非常详细,具有一定的参考价值,发现的小伙伴们可以参考一下:
成都创新互联主营宣城网站建设的网络公司,主营网站建设方案,成都app开发,宣城h5小程序制作搭建,宣城网站营销推广欢迎宣城等地区企业咨询
具体内容如下
#include"stdafx.h" //#include//#include #include #include #include using namespace cv; using namespace std; int main() { Mat src,smallImg,tmp,bigImg,gray,edges,masks,dst; const int MEDIAN_BLUR_FILTER_SIZE = 7; const int LAPLACIAN_FILTER_SIZE = 5; const int EDGES_THRESHOLD = 80; int repetitions = 7; // Repetitions for strong cartoon effect. src = imread("pic.jpg"); Size size = src.size(); Size smallSize; smallSize.width = size.width/2; smallSize.height = size.height/2; smallImg = Mat(smallSize, CV_8UC3); tmp = Mat(smallSize, CV_8UC3); dst= Mat(size,CV_8UC3); cvtColor(src,gray,CV_BGR2GRAY); medianBlur(gray,gray,MEDIAN_BLUR_FILTER_SIZE); Laplacian(gray, edges, CV_8U,LAPLACIAN_FILTER_SIZE); threshold(edges, masks,EDGES_THRESHOLD,255, THRESH_BINARY_INV); imshow("sketch:)", masks); waitKey(10); resize(src, smallImg, smallSize, 0,0, INTER_LINEAR); for (int i=0; i 以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持创新互联。
网站题目:使用OpenCV怎么将彩色照片转换成素描卡通照片
网址分享:http://chengdu.cdxwcx.cn/article/piospj.html