3 Star 0 Fork 0

lzq1357 / Modifying pictures

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
VisualFrame.py 3.84 KB
一键复制 编辑 原始数据 按行查看 历史
lzq1357 提交于 2021-07-26 23:15 . UI优化补充
"""
视觉效果:改变图像亮度、对比度,增强锐化、灰色模式等等。
# lzy #
"""
from PIL import Image, ImageFilter, ImageEnhance
from tkinter import *
import UI
from VariableFrame import VariableFrame
#
class VisualFrame(VariableFrame):
def __init__(self, canv, master=None):
VariableFrame.__init__(self, canv, master)
self.placeWidget()
def placeWidget(self):
"""
放置控件
"""
bcolor = UI.bg
fcolor = UI.fg
w = UI.rightWidth-12
h = 25
f = UI.font
fy = 5
dy = h+8
fx = 0
sx = 130
i=0
btn1 = Button(self, text="调亮",
bg=bcolor, fg=fcolor,
bitmap=UI.viewBmp, compound='left',
width=w, height=h,
font=f,
command=lambda:self.bright())
btn1.place(x=fx, y=fy+i*dy)
i += 1
btn2 = Button(self, text="调暗",
bg=bcolor, fg=fcolor,
bitmap=UI.viewBmp, compound='left',
width=w, height=h,
font=f,
command=lambda:self.dimming())
btn2.place(x=fx, y=fy+i*dy)
i += 1
btn3 = Button(self, text="黑白模式",
bg=bcolor, fg=fcolor,
bitmap=UI.viewBmp, compound='left',
width=w, height=h,
font=f,
command=lambda:self.bw())
btn3.place(x=fx, y=fy+i*dy)
i += 1
btn3 = Button(self, text="对比度减弱",
bg=bcolor, fg=fcolor,
bitmap=UI.viewBmp, compound='left',
width=w, height=h,
font=f,
command=lambda:self.color1())
btn3.place(x=fx, y=fy+i*dy)
i += 1
btn3 = Button(self, text="对比度增强",
bg=bcolor, fg=fcolor,
bitmap=UI.viewBmp, compound='left',
width=w, height=h,
font=f,
command=lambda:self.color2())
btn3.place(x=fx, y=fy+i*dy)
i += 1
btn3 = Button(self, text="模糊化",
bg=bcolor, fg=fcolor,
bitmap=UI.viewBmp, compound='left',
width=w, height=h,
font=f,
command=lambda:self.sharpness1())
btn3.place(x=fx, y=fy+i*dy)
i += 1
btn3 = Button(self, text="锐化",
bg=bcolor, fg=fcolor,
bitmap=UI.viewBmp, compound='left',
width=w, height=h,
font=f,
command=lambda:self.sharpness2())
btn3.place(x=fx, y=fy+i*dy)
def bright(self):#调亮
img1 = ImageEnhance.Brightness(self.canv.img).enhance(1.2)
self.canv.refresh(img1)
def dimming(self):#调暗
img2 = ImageEnhance.Brightness(self.canv.img).enhance(0.83)
self.canv.refresh(img2)
def bw(self):#黑白模式
img3= ImageEnhance.Color(self.canv.img).enhance(0.0)
self.canv.refresh(img3)
def color1(self):#对比度减弱
img4= ImageEnhance.Color(self.canv.img).enhance(0.83)
self.canv.refresh(img4)
def color2(self):#对比度增强
img5 = ImageEnhance.Color(self.canv.img).enhance(1.2)
self.canv.refresh(img5)
def sharpness1(self):#模糊化
img6= ImageEnhance.Sharpness(self.canv.img).enhance(0.66)
self.canv.refresh(img6)
def sharpness2(self):#锐化
img7= ImageEnhance.Sharpness(self.canv.img).enhance(1.5)
self.canv.refresh(img7)
#
Python
1
https://gitee.com/lzq1357/Modifying-pictures.git
git@gitee.com:lzq1357/Modifying-pictures.git
lzq1357
Modifying-pictures
Modifying pictures
master

搜索帮助