本文整理汇总了Python中PIL.ImageEnhance方法的典型用法代码示例。如果您正苦于以下问题:Python PIL.ImageEnhance方法的具体用法?Python PIL.ImageEnhance怎么用?Python PIL.ImageEnhance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PIL
的用法示例。
在下文中一共展示了PIL.ImageEnhance方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Sharpness
# 需要导入模块: import PIL [as 别名]
# 或者: from PIL import ImageEnhance [as 别名]
def Sharpness(img, v): # [0.1,1.9]
assert 0.1 <= v <= 1.9
return PIL.ImageEnhance.Sharpness(img).enhance(v)
示例2: Contrast
# 需要导入模块: import PIL [as 别名]
# 或者: from PIL import ImageEnhance [as 别名]
def Contrast(img, v): # [0.1,1.9]
assert 0.1 <= v <= 1.9
return PIL.ImageEnhance.Contrast(img).enhance(v)
示例3: Color
# 需要导入模块: import PIL [as 别名]
# 或者: from PIL import ImageEnhance [as 别名]
def Color(img, v): # [0.1,1.9]
assert 0.1 <= v <= 1.9
return PIL.ImageEnhance.Color(img).enhance(v)
示例4: Brightness
# 需要导入模块: import PIL [as 别名]
# 或者: from PIL import ImageEnhance [as 别名]
def Brightness(img, v): # [0.1,1.9]
assert 0.1 <= v <= 1.9
return PIL.ImageEnhance.Brightness(img).enhance(v)
示例5: Brightness
# 需要导入模块: import PIL [as 别名]
# 或者: from PIL import ImageEnhance [as 别名]
def Brightness(img, v, max_v, bias=0):
v = _float_parameter(v, max_v) + bias
return PIL.ImageEnhance.Brightness(img).enhance(v)
示例6: Color
# 需要导入模块: import PIL [as 别名]
# 或者: from PIL import ImageEnhance [as 别名]
def Color(img, v, max_v, bias=0):
v = _float_parameter(v, max_v) + bias
return PIL.ImageEnhance.Color(img).enhance(v)
示例7: Contrast
# 需要导入模块: import PIL [as 别名]
# 或者: from PIL import ImageEnhance [as 别名]
def Contrast(img, v, max_v, bias=0):
v = _float_parameter(v, max_v) + bias
return PIL.ImageEnhance.Contrast(img).enhance(v)
示例8: Sharpness
# 需要导入模块: import PIL [as 别名]
# 或者: from PIL import ImageEnhance [as 别名]
def Sharpness(img, v, max_v, bias=0):
v = _float_parameter(v, max_v) + bias
return PIL.ImageEnhance.Sharpness(img).enhance(v)
示例9: enhance
# 需要导入模块: import PIL [as 别名]
# 或者: from PIL import ImageEnhance [as 别名]
def enhance(self, image, layout='hcbs', factor=(1, 1, 1, 1)):
""" Apply enhancements from PIL.ImageEnhance to the image.
Parameters
----------
layout : str
defines layout of operations, default is `hcbs`:
h - color
c - contrast
b - brightness
s - sharpness
factor : float or tuple of float
factor of enhancement for each operation listed in `layout`.
"""
enhancements = {
'h': 'Color',
'c': 'Contrast',
'b': 'Brightness',
's': 'Sharpness'
}
if isinstance(factor, float):
factor = (factor,) * len(layout)
if len(layout) != len(factor):
raise ValueError("'layout' and 'factor' should be of same length!")
for alias, multiplier in zip(layout, factor):
enhancement = enhancements.get(alias)
if enhancement is None:
raise ValueError('Unknown enhancement alias: ', alias)
image = getattr(PIL.ImageEnhance, enhancement)(image).enhance(multiplier)
return image