It is also interesting to draw cartoons with opencv when you are idle, although the effect is not good (it cannot achieve the effect achieved above ),
The parameter needs to be adjusted. It is more suitable for images with large sizes and low noise.
You can also familiarize yourself with various filtering operations, such as bilateral filtering;
# Include "CV. H "# include" highgui. H "using namespace CV; using namespace STD; int main () {string name =" D:/cartoon0.jpg "; MAT src1 = imread (name, 1); mat img; // bilateral filtering. The first 3rd parameters d> 5 cannot be processed in real time. The last two parameters are Sigma parameters, which are generally the same. // <10 is basically ineffective.> bilateralfilter (src1, IMG, 150); bilateralfilter (IMG, src1, 5,150,150); // IMG. copyto (src1); imshow ("Bilateral", src1); waitkey (0); mat src; cvtcolor (src1, SRC, cv_bgr2gray); // The thicker the line, however, there will be a large amount of noise mat imgl; // The third parameter ddepth indicates the depth of the target image. When ddepth =-1, it is consistent with the original image Laplacian (SRC, imgl,-1, 3, 1); imshow ("Laplacian", imgl); waitkey (0); // fine line mat imgc; canny (SRC, imgc, 30, 90); imshow ("kan ", imgc); waitkey (0); MAT IMGs, imgsx, imgsy, imgs0; Sobel (SRC, imgsx,-, 1); Sobel (SRC, imgsx, 0); IMGs = imgsx + imgsy; Sobel (SRC, imgs0,-1, 1); imshow ("sobel0", imgs0); imshow ("Sobel", IMGs ); waitkey (0); MAT imgtotal; imgtotal = imgc + IMGs + imgl; // imgtotal. convertize (imgtotal, cv_32fc1); normalize (imgtotal, imgtotal, 255, 0, cv_minmax); convert (imgtotal, imgtotal, size (100,255), 3); threshold (imgtotal, imgtotal, values); imshow ("Total", imgtotal); waitkey (0); MAT imgtotalc3; cvtcolor (imgtotal, imgtotalc3, cv_gray2bgr); bitwise_and (src1, imgtotalc3, src1 ); imshow ("result", src1); waitkey (0); Name. insert (11, "_ edge"); imwrite (name, src1);/* mat IMG (imgtotal. rows, imgtotal. cols, cv_32fc1); For (INT I = 0; I (I, j) = 0) IMG. at <float> (I, j) = 1 ;}} imshow ("reverse", IMG); waitkey (0); * // * mat imgsc; Scharr (SRC, imgsc,-1, 1, 0); imshow ("Scharr", imgsc); waitkey (0 );*/}