Vizard 7 » Reference » Shaders » Post-Process Effects » Color effects
7.7

Color effects

The vizfx.postprocess.color library is a collection of effects that perform various color adjustments.

Grayscale

Convert the colors to grayscale.

import vizfx.postprocess
from vizfx.postprocess.color import GrayscaleEffect
effect = GrayscaleEffect()
vizfx.postprocess.addEffect(effect)

Sepia

Convert the colors to a sepia tone.

import vizfx.postprocess
from vizfx.postprocess.color import SepiaToneEffect
effect = SepiaToneEffect()
vizfx.postprocess.addEffect(effect)

Bleach Bypass

Applies a bleach bypass effect on the image, which simulates the skipping of the bleaching function during the processing of color film.

import vizfx.postprocess
from vizfx.postprocess.color import BleachBypassEffect
effect = BleachBypassEffect()
vizfx.postprocess.addEffect(effect)

Invert

Invert the colors.

import vizfx.postprocess
from vizfx.postprocess.color import InvertColorEffect
effect = InvertColorEffect()
vizfx.postprocess.addEffect(effect)

Color Offset

Apply an offset to each color channel.

Constructor

Description

ColorOffsetEffect(

    red = 0.0,

    green = 0.0,

    blue = 0.0

)

Create the color offset effect with the initial red, green, and blue offset values.

 

Method

Description

<effect>.setRedOffset(offset)

Set the offset for the red channel.

<effect>.getRedOffset()

Get the offset for the red channel.

<effect>.setGreenOffset(offset)

Set the offset for the green channel.

<effect>.getGreenOffset()

Get the offset for the green channel.

<effect>.setBlueOffset(offset)

Set the offset for the blue channel.

<effect>.getBlueOffset()

Get the offset for the blue channel.

<effect>.setColorOffset(offset)

Set the offset for the red, green, and blue channels using the specified 3-item list.

<effect>.getColorOffset()

Get the offset for the red, green, and blue channels.

This effect can be registered with vizconfig.

import vizfx.postprocess
from vizfx.postprocess.color import ColorOffsetEffect
effect = ColorOffsetEffect()
effect.setColorOffset([0.5,0.5,-0.2])
vizfx.postprocess.addEffect(effect)

Color Scale

Apply a scale factor to each color channel.

Constructor

Description

ColorScaleEffect(

    red = 1.0,

    green = 1.0,

    blue = 1.0

)

Create the color scale effect with the initial red, green, and blue scale factors.

 

Method

Description

<effect>.setRedScale(scale)

Set the scale factor for the red channel.

<effect>.getRedScale()

Get the scale factor for the red channel.

<effect>.setGreenScale(scale)

Set the scale factor for the green channel.

<effect>.getGreenScale()

Get the scale factor for the green channel.

<effect>.setBlueScale(scale)

Set the scale factor for the blue channel.

<effect>.getBlueScale()

Get the scale factor for the blue channel.

<effect>.setColorScale(scale)

Set the scale factor for the red, green, and blue channels using the specified 3-item list.

<effect>.getColorScale()

Get the scale factor for the red, green, and blue channels.

This effect can be registered with vizconfig.

import vizfx.postprocess
from vizfx.postprocess.color import ColorScaleEffect
effect = ColorScaleEffect()
effect.setRedScale(2.0)
effect.setGreenScale(1.5)
vizfx.postprocess.addEffect(effect)

Color Correction

Apply color correction to the image similar to the "curves" tool found in many popular image editing programs (e.g. Photoshop, Paint.NET).

 

The effect uses a 256 x 1 lookup texture to perform the color correction. You can use the following steps to create a lookup texture:

  1. Open the template lookup texture (template.png located in the [Vizard]/resources/color_correction folder) into your image editing program.
  2. Use the "Curves" tool to create the desired color correction and apply it to the image.
  3. Save the image to a new file (png format is recommended).

Lookup texture used for the image above:

Constructor

Description

ColorCorrectionEffect(texture)

Create the color correction effect using the specified lookup texture.

import vizfx.postprocess
from vizfx.postprocess.color import ColorCorrectionEffect
texture = viz.addTexture('color_correction/xpro.png')
effect = ColorCorrectionEffect(texture)
vizfx.postprocess.addEffect(effect)

Brightness

Control the brightness of the image.

Constructor

Description

BrightnessEffect(brightness = 0.0)

Create the brightness effect with the initial brightness value. The brightness value can range from -1 to 1.

 

Method

Description

<effect>.setBrightness(value)

Set the brightness value.

<effect>.getBrightness()

Get the brightness value.

This effect can be registered with vizconfig.

import vizfx.postprocess
from vizfx.postprocess.color import BrightnessEffect
effect = BrightnessEffect(0.5)
vizfx.postprocess.addEffect(effect)

Contrast

Control the contrast of the image.

Constructor

Description

ContrastEffect(contrast = 0.0)

Create the contrast effect with the initial contrast value. The contrast value can range from -1 to 1.

 

Method

Description

<effect>.setContrast(value)

Set the contrast value.

<effect>.getContrast()

Get the contrast value.

This effect can be registered with vizconfig.

import vizfx.postprocess
from vizfx.postprocess.color import ContrastEffect
effect = ContrastEffect(0.3)
vizfx.postprocess.addEffect(effect)

Exposure

Control the exposure of the image.

Constructor

Description

ExposureEffect(exposure= 0.0)

Create the exposure effect with the initial exposure value.

 

Method

Description

<effect>.setExposure(value)

Set the exposure value. A positive value will over-expose the image. A negative value will under-expose the image.

<effect>.getExposure()

Get the exposure value.

This effect can be registered with vizconfig.

import vizfx.postprocess
from vizfx.postprocess.color import ExposureEffect
effect = ExposureEffect(1.0)
vizfx.postprocess.addEffect(effect)

Hue

Adjust the image hue.

Constructor

Description

HueEffect(hue= 0.0)

Create the hue effect with the initial hue value.

 

Method

Description

<effect>.setHue(value)

Set the hue value. The value ranges from -1 to 1.

<effect>.getHue()

Get the hue value.

This effect can be registered with vizconfig.

import vizfx.postprocess
from vizfx.postprocess.color import HueEffect
effect = HueEffect(0.2)
vizfx.postprocess.addEffect(effect)

Saturation

Adjust the image saturation.

Constructor

Description

SaturationEffect(saturation= 0.0)

Create the saturation effect with the initial saturation value.

 

Method

Description

<effect>.setSaturation(value)

Set the saturation value. The value ranges from -1 to 1. Positive values saturate, and negative values desaturate.

<effect>.getSaturation()

Get the saturation value.

This effect can be registered with vizconfig.

import vizfx.postprocess
from vizfx.postprocess.color import SaturationEffect
effect = SaturationEffect(0.5)
vizfx.postprocess.addEffect(effect)

Vibrance

Adjust image vibrance by modifying saturation of desaturated colors.

Constructor

Description

VibranceEffect(vibrance= 0.0)

Create the vibrance effect with the initial vibrance value.

 

Method

Description

<effect>.setVibrance(value)

Set the vibrance value. The value ranges from -1 to 1. Positive values add vibrance, and negative values remove vibrance.

<effect>.getVibrance()

Get the vibrance value.

This effect can be registered with vizconfig.

import vizfx.postprocess
from vizfx.postprocess.color import VibranceEffect
effect = VibranceEffect(1.0)
vizfx.postprocess.addEffect(effect)

Gamma Correction

Applies gamma correction to the image.

Constructor

Description

GammaCorrectionEffect(gamma = 1.0)

Create the gamma correction effect with the initial gamma value. Most displays and graphics cards support gamma correction, so this effect is usually unnecessary. Most displays have a gamma of approximately 2.2.

 

Method

Description

<effect>.setGamma(value)

Set the gamma value.

<effect>.getGamma()

Get the gamma value.

This effect can be registered with vizconfig.

import vizfx.postprocess
from vizfx.postprocess.color import GammaCorrectionEffect
effect = GammaCorrectionEffect(2.2)
vizfx.postprocess.addEffect(effect)

Posterize

Posterizes the image (reduces number of increments in the color values).

Constructor

Description

PosterizeEffect(increments = 255)

Create the posterize effect with the initial number of color value increments.

 

Method

Description

<effect>.setIncrements(value)

Set the number of color value increments.

<effect>.getIncrements()

Get the number of color value increments.

This effect can be registered with vizconfig.

import vizfx.postprocess
from vizfx.postprocess.color import PosterizeEffect
effect = PosterizeEffect(6)
vizfx.postprocess.addEffect(effect)

Post-Process Basics

Color Effects

Distort Effects

Blur Effects

Transform Effects

Composite Effects