colortransforms.q

Various utility functions for performing color conversions/transformations/etc.

Summary
colortransforms.qVarious utility functions for performing color conversions/transformations/etc.
Functions
is_rgbReturns true only if the image is an RGB image
is_grayReturns true only if the image is a grayscale image
color_covComputes the color band covariance matrix of an image
PCA_color_transformComputes the color decorrelating transform using Principal Component Analysis (PCA) in the L2 sense
L1PCA_color_transformComputes the color decorrelating transform using Principal Component Analysis (PCA) in the L1 sense
get_colortransform_from_RGB
colortransformApply the specified color transform to an image
rgb2grayConversion from RGB to grayscale
gray2rgbConversion from grayscale to RGB
compute_hueComputes the HUE value of a given RGB color value
rgb2hsv_devicefuncConversion from RGB to Hue-Saturation-Value (HSV)
rgb2hsv_devicefuncConversion from RGB to Hue-Saturation-Luminance (HSL)
rgb2hsvConversion from RGB to Hue-Saturation-Value (HSV)
rgb2hslConversion from RGB to Hue-Saturation-Luminance (HSL)
rgb2hsv_devicefuncConversion from Hue-Saturation-Value (HSV) to RGB
hsv2rgbConversion from Hue-Saturation-Value (HSV) to RGB
hsl2rgb_devicefuncConversion from Hue-Saturation-Lightness (HSL) to RGB
hsl2rgbConversion from Hue-Saturation-Lightness (HSL) to RGB
rgb2labConversion from RGB to the CIELAB color space
hsl_correctPerforms Hue-Saturation-Lightness correction of an image

Functions

is_rgb

Returns true only if the image is an RGB image

is_gray

Returns true only if the image is a grayscale image

color_cov

Computes the color band covariance matrix of an image

PCA_color_transform

Computes the color decorrelating transform using Principal Component Analysis (PCA) in the L2 sense

[U, Ut] = PCA_color_transform(img)

Parameters

imgthe input image
UThe decorrelating transform
UtThe transpose of the decorrelating transform

L1PCA_color_transform

Computes the color decorrelating transform using Principal Component Analysis (PCA) in the L1 sense

[U, Ut] = L1PCA_color_transform(img)

Parameters

imgthe input image
UThe decorrelating transform
UtThe transpose of the decorrelating transform

get_colortransform_from_RGB

Get the specified color transform [Noteonly a couple of linear color transforms are supported here]
[U, Ut] = get_colortransform_from_RGB(colorspace, img = 0)

Parameters

colorspacesupported color spaces are “RGB”, “PCA”, “YCbCr”, “YUV”
imgthe input image (in case of “PCA”)
UThe forward color transform
UinvThe inverse color transform

colortransform

Apply the specified color transform to an image

function y = colortransform(C, x)

Parameters

Ca 3x3 color transform matrix (or a scalar value)
xan input image image of dimensions MxNx3
ythe color transformed output image

rgb2gray

Conversion from RGB to grayscale

function y = rgb2gray(x)

gray2rgb

Conversion from grayscale to RGB

function y = gray2rgb(x)

compute_hue

Computes the HUE value of a given RGB color value

function h : scalar = __device__ compute_hue (c : vec3)

rgb2hsv_devicefunc

Conversion from RGB to Hue-Saturation-Value (HSV)

function [y : vec3] = __device__ rgb2hsv_devicefunc (c : vec3)

rgb2hsv_devicefunc

Conversion from RGB to Hue-Saturation-Luminance (HSL)

function [y : vec3] = __device__ rgb2hsv_devicefunc (c : vec3)

rgb2hsv

Conversion from RGB to Hue-Saturation-Value (HSV)

function y = rgb2hsv(x)

rgb2hsl

Conversion from RGB to Hue-Saturation-Luminance (HSL)

function y = rgb2hsl(x)

rgb2hsv_devicefunc

Conversion from Hue-Saturation-Value (HSV) to RGB

function [y : vec3] = __device__ hsv2rgb_devicefunc (c : vec3)

hsv2rgb

Conversion from Hue-Saturation-Value (HSV) to RGB

function [y : vec3] = __device__ hsv2rgb (c : vec3)

hsl2rgb_devicefunc

Conversion from Hue-Saturation-Lightness (HSL) to RGB

function [y : vec3] = __device__ hsl2rgb_devicefunc (c : vec3)

hsl2rgb

Conversion from Hue-Saturation-Lightness (HSL) to RGB

function y = hsl2rgb(x)

rgb2lab

Conversion from RGB to the CIELAB color space

function y = rgb2lab(x)

hsl_correct

Performs Hue-Saturation-Lightness correction of an image

function [] = hsl_correct(img_in, img_out, add_hue, add_saturation, add_lightness)

Parameters

img_ininput image
img_outoutput image
add_huethe amount of hue to add (hue values are in the range [0,1])
add_saturationthe amount of saturation to add
add_lightnessthe amount of lightness to add

Remarks

the values of add_hue, add_saturation, add_lightness can also be negative.

Close