Recently, the major social media have been swiped by Gu ailing , It's just 2 month 8 The morning of , She won the championship in the freestyle skiing women's platform diving competition in the Beijing Winter Olympics , He won the highest score in the game with a difficult action he has never tried on the field .
More Than This , Gu ailing 17 I already had... At the age of More than 60 medals , Only in 2021-2022 The world cup of the season won 6 gold 2 silver 1 Copper 9 A medal . Except skiing , Will The piano 、 Equestrian 、 Ballet , Because I like running , And almost became athletes .
She is also a learning bully , With 1580 Points of SAT( College entrance examination for American high school students , Full marks 1600) I was admitted to Stanford University . She's also involved Fashion , Become the darling of many fashion brands and publications .
This is not proper “ Somebody else's child ” Well , No wonder her mother was ridiculed as “ Mother's ceiling in Haidian District ”. Today, Xiaobian will lead you through Python To draw the cartoon image of Gu ailing , Finally, the effect drawn is shown in the figure below
Now let's take a look at the specific code
① Python e-book ( And classic books )
② Python Standard library information ( The most complete Chinese version )
③ Project source code ( Forty or fifty interesting and reliable hand training projects and source code )
④ Python Basic introduction 、 Reptiles 、 Network development 、 Big data analysis video ( Suitable for Xiaobai to learn )
⑤ Python Learning Roadmap ( Farewell to bad learning )
Scan the end of the text to get a large number of Python Learning resources
raw_img = cv2.imread(fn_raw)
img_resized = cv2.resize(raw_img, (width, height))
cv2.imshow('img_resized', img_resized)
img_gray = cv2.cvtColor(img_resize, cv2.COLOR_BGR2GRAY)
img_blur = cv2.medianBlur(img_gray, 5)
First, we convert the input image into a grayscale image , Then the median filter is processed , Use each pixel as a field ( A square area centered on the current pixel ) The median value of the pixel is used instead of , Remove some noise , Avoid too many boundary points , The following is the boundary detection
img_canny_edge = cv2.Canny(img_blur, 80, 160, apertureSize=3)
output
The next step is to binarize the boundary , The code is as follows
_, img_masked = cv2.threshold(img_canny_edge, 100, 255, cv2.THRESH_BINARY_INV)
img_masked = cv2.cvtColor(img_masked, cv2.COLOR_GRAY2BGR)
output
Finally, smooth the image , And merge the smoothed image with the previously obtained edge , Get the picture of the final cartoon image , The code is as follows
img_cartoon = cv2.bitwise_and(img_cartoon, img_masked)
cv2.imshow('cartoon-' + edge, img_cartoon)
cv2.imwrite("cartoon-" + fn_raw, img_cartoon)
cv2.waitKey()
output
Learn from good examples Python Whether it's employment or sideline, it's good to make money , But learn to Python Still have a learning plan . Finally, let's share a complete set of Python Learning materials , For those who want to learn Python Let's have a little help !
Here is the Python The commonly used technical points have been sorted out , There is a summary of knowledge points in various fields , You can find the corresponding learning resources according to the above knowledge points .
Python Common development software , It will save you a lot of time .
Programming learning must watch more videos , Combine books and videos to get twice the result with half the effort .
Optical theory is useless , When learning programming, never talk on paper , Be sure to practice , Apply what you have learned to practice .
Finally, I wish you progress every day !!
The full version above Python The full set of learning materials has been uploaded to CSDN official , Friends can scan the bottom of wechat directly if necessary CSDN The official two-dimensional code is free 【 Guarantee 100% free 】.