Color Examples¶
[1]:
from easycv import Image, Pipeline
from easycv.transforms import GrayScale, Sepia, FilterChannels, GammaCorrection, Negative, Cartoon, PhotoSketch, ColorTransfer, Colorize, ColorPick, Quantitization, Hue, Contrast, Brightness, Hsv
For this example we will load an image with random(). For more examples of image loading check Image examples.
[2]:
img = Image.random()
img
[2]:
Gray Scale¶
To convert the image to grayscale we just need to apply the transform, for more information check the reference.
[3]:
img.apply(GrayScale())
[3]:
Sepia¶
To convert the image to grayscale we just need to apply the transform, for more information check the reference.
[4]:
img.apply(Sepia())
[4]:
Filter Channels¶
To remove a channel we just need to apply the transform with a list of the channels to remove, for more information check the reference.
[5]:
img.apply(FilterChannels(channels=[1]))
[5]:
Gamma Correction¶
To apply gamma correction we just need to apply the transform with a new gamma value, for more information check the reference.
[6]:
img.apply(GammaCorrection(gamma=3.0))
[6]:
[7]:
img.apply(GammaCorrection(gamma=0.5))
[7]:
Negative¶
To convert the image to negative we just need to apply the transform, for more information check the reference.
[8]:
img.apply(Negative())
[8]:
Cartoon¶
To make an image look like a Cartoon we just need to apply the transform, for more information check the reference.
[9]:
img.apply(Cartoon())
[9]:
Photo Sketch¶
To make an image look like a pencil sketch we just need to apply the transform, for more information check the reference.
[10]:
img.apply(PhotoSketch())
[10]:
Color Transfer¶
To transfer the colors from source to target we just need to apply the transform, for more information check the reference.
[11]:
src = Image("images/source.jpg")
src
[11]:
[12]:
img.apply(ColorTransfer(source=src))
[12]:
Color Pick¶
To pick the color from the desired point or rectangle we just need to apply the transform, for more information check the reference.
[13]:
img.apply(ColorPick(method="point"))
[13]:
{'color': [127, 116, 120]}
Colorize¶
To colorize an image apply the Colorize transform to a grayscale image, for more information check the reference.
[14]:
gray = img.apply(GrayScale())
gray
[14]:
[15]:
gray.apply(Colorize())
[15]:
Quantitization¶
To reduce the number of colors of an image apply the Quantitization with the number of colors, for more information check the reference.
[16]:
img.apply(Quantitization(clusters=8))
[16]:
Hue¶
To add hue to an image apply the Hue with the value to add, for more information check the reference.
[17]:
img.apply(Hue(value=10))
[17]:
Contrast¶
To add contrast to an image apply the Contrast with alpha value of contrast to add, for more information check the reference.
[18]:
img.apply(Contrast(alpha=1.4))
[18]:
Brightness¶
To add brightness to an image apply the Brightness brightness to add, for more information check the reference.
[19]:
img.apply(Brightness(beta=10))
[19]:
Hsv¶
To reduce the number of colors of an image apply the Quantitization with the number of colors, for more information check the reference.
[20]:
img.apply(Hsv())
[20]: