In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to use Python3 code to add beauty effect to pictures", the content in the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "how to use Python3 code to add beauty effect to pictures" bar!
1 module installation
Because it is a third-party module, the old rule, the first step, install:
Pip install pillow
For other installation methods, please read these two articles directly:
Python3 automatically installs third-party libraries to say goodbye to pip
Python: one line of code to import all Python libraries
Here is a simple sentence:
The class of ImageEnhance in the PIL module is specially used for image enhancement processing
It can not only enhance (or weaken) the brightness, contrast and chromaticity of the image, but also can be used to enhance the sharpness of the image.
After the installation, you also understand the class methods, and then you will practice the code.
2 read the image
Code example:
#-*-coding:utf-8-*-# @ Time: 2022-04-pictures @ Author: carl_DJfrom PIL import Image,ImageEnhance "read pictures" image = Image.open ('. / data/mm.jpg') image.show ()
Running result
The open picture is the original picture.
3 enhance brightness
Code example:
#-*-coding:utf-8-*-# @ Time: 2022-04-reading @ Author: carl_DJfrom PIL import Image,ImageEnhance "read picture" image = Image.open ('. / data/mm.jpg') # image.show () "enhance brightness" bright_enh = ImageEnhance.Brightness (image) # adjust luminance value brightness = 3image_brightened = bright_enh.enhance (brightness) image_brightened.show ()
Running result:
4 enhanced chromaticity
Code example:
#-*-coding:utf-8-*-# @ Time: 2022-04-read @ Author: carl_DJfrom PIL import Image,ImageEnhance "read picture" image = Image.open ('. / data/mm.jpg') # image.show () "enhanced chromaticity" color_enh = ImageEnhance.Color (image) # adjust chromaticity color = 3image_colored = color_enh.enhance (color) image_colored.show ()
Running result:
5 enhance the contrast
Code example:
#-*-coding:utf-8-*-# @ Time: 2022-04-pictures @ Author: carl_DJfrom PIL import Image,ImageEnhance "read picture" image = Image.open ('. / data/mm.jpg') # image.show () "enhance contrast" contrast_enh = ImageEnhance.Contrast (image) # adjust contrast contrast = 3image_contrasted = contrast_enh.enhance (contrast) image_contrasted.show ()
Running result:
6 sharpening
Code example:
#-*-coding:utf-8-*-# @ Time: 2022-04-pictures @ Author: carl_DJfrom PIL import Image,ImageEnhance "read picture" image = Image.open ('. / data/mm.jpg') # image.show () "enhance contrast" contrast_enh = ImageEnhance.Contrast (image) # adjust contrast contrast = 3image_contrasted = contrast_enh.enhance (contrast) image_contrasted.show ()
Running result:
Thank you for your reading, the above is the content of "how to use Python3 code to add beauty effect to pictures". After the study of this article, I believe you have a deeper understanding of how to use Python3 code to add beauty effect to pictures. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.