使用OpenCV怎么将彩色照片转换成素描卡通照片

  介绍

这篇文章主要为大家详细介绍了使用OpenCV怎么将彩色照片转换成素描卡通照片,文中示例代码介绍的非常详细,具有一定的参考价值,发现的小伙伴们可以参考一下:

具体内容如下

# include" stdafx.h"//# include//# include   ,   # include  & lt; opencv2/highgui/highgui.hpp>   # include  & lt; opencv2/imgproc/imgproc.hpp>   # include  & lt; opencv2/核心/core.hpp>   using  namespace 简历;   using  namespace 性传播疾病;   ,   ,   int  main ()   {   ,Mat  src, smallImg、tmp bigImg,灰色,边缘,面具,dst,,   ,const  int  MEDIAN_BLUR_FILTER_SIZE =, 7,,   ,const  int  LAPLACIAN_FILTER_SIZE =, 5,,   ,const  int  EDGES_THRESHOLD =,, 80;   7,int  repetitions =,,,//, repetitions  for  strong  cartoon 又是生效;   ,=,,src  imread (“pic.jpg");   ,   ,Size  Size =, src.size (),,   ,Size 适用;=,smallSize.width 宽度/2,,=,,smallSize.height  size.height/2,,=,,smallImg 垫(适用,CV_8UC3),,=,,tmp 垫(适用,CV_8UC3),,   ,dst=垫(大小、CV_8UC3);,   ,   ,cvtColor (src、灰色CV_BGR2GRAY);,   ,   ,medianBlur(灰色、灰色MEDIAN_BLUR_FILTER_SIZE);,   ,   ,拉普拉斯算子(灰色,边缘,,CV_8U, LAPLACIAN_FILTER_SIZE),,   ,   ,阈值(边缘,面具,EDGES_THRESHOLD, 255年,THRESH_BINARY_INV),,   ,imshow(“素描:),,,面具),,   ,waitKey (10);   ,   ,调整(src, smallImg,,适用的,,0,0,,INTER_LINEAR),,   ,for  (int  i=0, i<重复;,我+ +),   {大敌;   9,int  ksize =,,,//, Filter 大小只Has  a  large  effect 提醒速度又是;   9,double  sigmaColor =,,,//, Filter  color 力量又是;   7,double  sigmaSpace =,,,//, Spatial 强度只Affects 速度又是;   ,bilateralFilter (smallImg, tmp, ksize,, sigmaColor,, sigmaSpace),,   ,bilateralFilter (tmp, smallImg,, ksize,, sigmaColor,, sigmaSpace),,   }大敌;   ,调整(smallImg, bigImg,,,, 0, 0,, INTER_LINEAR),,   面具,bigImg.copyTo (dst),,   ,   ,imshow (“cartoon :),,, dst),,   ,waitKey (0);   ,return  0;   }

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

使用OpenCV怎么将彩色照片转换成素描卡通照片