這篇文章主要為大家詳細介紹了使用OpenCV怎么將彩色照片轉(zhuǎn)換成素描卡通照片,文中示例代碼介紹的非常詳細,具有一定的參考價值,發(fā)現(xiàn)的小伙伴們可以參考一下:
成都創(chuàng)新互聯(lián)主營宣城網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,成都app開發(fā),宣城h5小程序制作搭建,宣城網(wǎng)站營銷推廣歡迎宣城等地區(qū)企業(yè)咨詢
具體內(nèi)容如下
#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 以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持創(chuàng)新互聯(lián)。
網(wǎng)頁名稱:使用OpenCV怎么將彩色照片轉(zhuǎn)換成素描卡通照片
分享URL:http://weahome.cn/article/piospj.html