本文整理匯總了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