Python PIL.ImageEnhance() Examples

The following are 30 code examples of PIL.ImageEnhance(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PIL , or try the search function .
Example #1
Source File: augmentations.py    From pytorch-randaugment with MIT License 5 votes vote down vote up
def Contrast(img, v):  # [0.1,1.9]
    assert 0.1 <= v <= 1.9
    return PIL.ImageEnhance.Contrast(img).enhance(v) 
Example #2
Source File: augmentations.py    From fast-autoaugment with MIT License 5 votes vote down vote up
def Color(img, v):  # [0.1,1.9]
    assert 0.1 <= v <= 1.9
    return PIL.ImageEnhance.Color(img).enhance(v) 
Example #3
Source File: augmentations.py    From fast-autoaugment with MIT License 5 votes vote down vote up
def Brightness(img, v):  # [0.1,1.9]
    assert 0.1 <= v <= 1.9
    return PIL.ImageEnhance.Brightness(img).enhance(v) 
Example #4
Source File: augmentations.py    From fast-autoaugment with MIT License 5 votes vote down vote up
def Sharpness(img, v):  # [0.1,1.9]
    assert 0.1 <= v <= 1.9
    return PIL.ImageEnhance.Sharpness(img).enhance(v) 
Example #5
Source File: batch_image.py    From batchflow with Apache License 2.0 5 votes vote down vote up
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 
Example #6
Source File: augmentations.py    From cutmix with MIT License 5 votes vote down vote up
def Contrast(img, v):  # [0.1,1.9]
    assert 0.1 <= v <= 1.9
    return PIL.ImageEnhance.Contrast(img).enhance(v) 
Example #7
Source File: augmentations.py    From cutmix with MIT License 5 votes vote down vote up
def Color(img, v):  # [0.1,1.9]
    assert 0.1 <= v <= 1.9
    return PIL.ImageEnhance.Color(img).enhance(v) 
Example #8
Source File: augmentations.py    From cutmix with MIT License 5 votes vote down vote up
def Brightness(img, v):  # [0.1,1.9]
    assert 0.1 <= v <= 1.9
    return PIL.ImageEnhance.Brightness(img).enhance(v) 
Example #9
Source File: augmentations.py    From cutmix with MIT License 5 votes vote down vote up
def Sharpness(img, v):  # [0.1,1.9]
    assert 0.1 <= v <= 1.9
    return PIL.ImageEnhance.Sharpness(img).enhance(v) 
Example #10
Source File: augmentations.py    From fast-autoaugment with MIT License 5 votes vote down vote up
def Contrast(img, v):  # [0.1,1.9]
    assert 0.1 <= v <= 1.9
    return PIL.ImageEnhance.Contrast(img).enhance(v) 
Example #11
Source File: augmentations.py    From pytorch-randaugment with MIT License 5 votes vote down vote up
def Color(img, v):  # [0.1,1.9]
    assert 0.1 <= v <= 1.9
    return PIL.ImageEnhance.Color(img).enhance(v) 
Example #12
Source File: augmentations.py    From pytorch-randaugment with MIT License 5 votes vote down vote up
def Brightness(img, v):  # [0.1,1.9]
    assert 0.1 <= v <= 1.9
    return PIL.ImageEnhance.Brightness(img).enhance(v) 
Example #13
Source File: augmentations.py    From pytorch-randaugment with MIT License 5 votes vote down vote up
def Sharpness(img, v):  # [0.1,1.9]
    assert 0.1 <= v <= 1.9
    return PIL.ImageEnhance.Sharpness(img).enhance(v) 
Example #14
Source File: augment.py    From autogluon with Apache License 2.0 5 votes vote down vote up
def Contrast(img, v):  # [0.1,1.9]
    assert 0.1 <= v <= 1.9
    return PIL.ImageEnhance.Contrast(img).enhance(v) 
Example #15
Source File: augment.py    From autogluon with Apache License 2.0 5 votes vote down vote up
def Color(img, v):  # [0.1,1.9]
    assert 0.1 <= v <= 1.9
    return PIL.ImageEnhance.Color(img).enhance(v) 
Example #16
Source File: augment.py    From autogluon with Apache License 2.0 5 votes vote down vote up
def Brightness(img, v):  # [0.1,1.9]
    assert 0.1 <= v <= 1.9
    return PIL.ImageEnhance.Brightness(img).enhance(v) 
Example #17
Source File: augment.py    From autogluon with Apache License 2.0 5 votes vote down vote up
def Sharpness(img, v):  # [0.1,1.9]
    assert 0.1 <= v <= 1.9
    return PIL.ImageEnhance.Sharpness(img).enhance(v) 
Example #18
Source File: augmentations.py    From autoclint with Apache License 2.0 5 votes vote down vote up
def Contrast(img, v):  # [0.1,1.9]
    assert 0.1 <= v <= 1.9
    return PIL.ImageEnhance.Contrast(img).enhance(v) 
Example #19
Source File: augmentations.py    From unsupervised-data-augmentation with Apache License 2.0 5 votes vote down vote up
def Sharpness(img, v):  # [0.1,1.9]
    assert 0.1 <= v <= 1.9
    return PIL.ImageEnhance.Sharpness(img).enhance(v) 
Example #20
Source File: augmentations.py    From unsupervised-data-augmentation with Apache License 2.0 5 votes vote down vote up
def Brightness(img, v):  # [0.1,1.9]
    assert 0.1 <= v <= 1.9
    return PIL.ImageEnhance.Brightness(img).enhance(v) 
Example #21
Source File: augmentations.py    From unsupervised-data-augmentation with Apache License 2.0 5 votes vote down vote up
def Color(img, v):  # [0.1,1.9]
    assert 0.1 <= v <= 1.9
    return PIL.ImageEnhance.Color(img).enhance(v) 
Example #22
Source File: augmentations.py    From unsupervised-data-augmentation with Apache License 2.0 5 votes vote down vote up
def Contrast(img, v):  # [0.1,1.9]
    assert 0.1 <= v <= 1.9
    return PIL.ImageEnhance.Contrast(img).enhance(v) 
Example #23
Source File: randAug.py    From Tricks-of-Semi-supervisedDeepLeanring-Pytorch with MIT License 5 votes vote down vote up
def Sharpness(img, v, max_v, bias=0):
    v = _float_parameter(v, max_v) + bias
    return PIL.ImageEnhance.Sharpness(img).enhance(v) 
Example #24
Source File: randAug.py    From Tricks-of-Semi-supervisedDeepLeanring-Pytorch with MIT License 5 votes vote down vote up
def Contrast(img, v, max_v, bias=0):
    v = _float_parameter(v, max_v) + bias
    return PIL.ImageEnhance.Contrast(img).enhance(v) 
Example #25
Source File: randAug.py    From Tricks-of-Semi-supervisedDeepLeanring-Pytorch with MIT License 5 votes vote down vote up
def Color(img, v, max_v, bias=0):
    v = _float_parameter(v, max_v) + bias
    return PIL.ImageEnhance.Color(img).enhance(v) 
Example #26
Source File: randAug.py    From Tricks-of-Semi-supervisedDeepLeanring-Pytorch with MIT License 5 votes vote down vote up
def Brightness(img, v, max_v, bias=0):
    v = _float_parameter(v, max_v) + bias
    return PIL.ImageEnhance.Brightness(img).enhance(v) 
Example #27
Source File: autoaug.py    From PyTorch-Encoding with MIT License 5 votes vote down vote up
def Sharpness(img, v):  # [0.1,1.9]
    assert 0.1 <= v <= 1.9
    return PIL.ImageEnhance.Sharpness(img).enhance(v) 
Example #28
Source File: autoaug.py    From PyTorch-Encoding with MIT License 5 votes vote down vote up
def Brightness(img, v):  # [0.1,1.9]
    assert 0.1 <= v <= 1.9
    return PIL.ImageEnhance.Brightness(img).enhance(v) 
Example #29
Source File: autoaug.py    From PyTorch-Encoding with MIT License 5 votes vote down vote up
def Color(img, v):  # [0.1,1.9]
    assert 0.1 <= v <= 1.9
    return PIL.ImageEnhance.Color(img).enhance(v) 
Example #30
Source File: autoaug.py    From PyTorch-Encoding with MIT License 5 votes vote down vote up
def Contrast(img, v):  # [0.1,1.9]
    assert 0.1 <= v <= 1.9
    return PIL.ImageEnhance.Contrast(img).enhance(v)