buildgradient

From DavinciWiki
Jump to: navigation, search

Description

Builds a 1-dimensional colour gradient from an arbitrary number of colour control points

Arguments and Return Values

Arguments: the width/size of the gradient, an optional smoothing window, and at least two control points

Return Value: A one-dimensional RGB image

Usage

Syntax: buildgradient(point1position, point1colour ... pointnposition, pointncolour [, width = INT] [, smoothwindow = INT])


buildgradient() builds a 1-dimensional colour gradient from the specified parameters, similar to the gradient editor in Adobe Photoshop® and the GNU Image Manipulation Program.

It is mainly intended for use as one of the inputs to the applypalette function.

This function accepts an arbitrary number of colour control points. Each point is defined by two input variables, with the first representing its position along the gradient (starting at 1), and the second representing its colour in RGB colourspace.

The optional width parameter controls the size of the gradient. If it is not specified, it defaults to 65536.

The optional smoothwindow parameter specifies a sliding window (in terms of pixels) which is used to smooth the generated gradient. If it is not specified, it defaults to 1 (no smoothing).

Each colour should be specified as a 1x1x3 float array representing the RGB value, with each component between 0.0 and 1.0.

In the following examples, the resulting 1-dimensional gradients have been scaled into 2-dimensional images of a reasonable size for display. The commands to do this have been omitted to save space.


Examples

The 'Doppler Shift White' colour gradient from The Mirror's Surface Breaks:

dv> gradient_colour_00
1x1x3 array of float, bsq format [12 bytes]
1.000000000
0.0000000000
0.0000000000

dv> gradient_colour_01
1x1x3 array of float, bsq format [12 bytes]
1.000000000
1.000000000
1.000000000

dv> gradient_colour_02
1x1x3 array of float, bsq format [12 bytes]
0.0000000000
0.0000000000
1.000000000

dv> g = buildgradient(1, gradient_colour_00, 32768, gradient_colour_01, 65536, gradient_colour_02)
Generating a gradient using 3 colours and 3 channels.
65536x1x3 array of float, bsq format [786,432 bytes]

Gradient-01-DSW.PNG

The 'Hue Wheel' colour gradient from The Mirror's Surface Breaks:

dv> gradient_colour_00
1x1x3 array of float, bsq format [12 bytes]
1.000000000
0.0000000000
0.0000000000

dv> gradient_colour_01
1x1x3 array of float, bsq format [12 bytes]
1.000000000
1.000000000
0.0000000000

dv> gradient_colour_02
1x1x3 array of float, bsq format [12 bytes]
0.0000000000
1.000000000
0.0000000000

dv> gradient_colour_03
1x1x3 array of float, bsq format [12 bytes]
0.0000000000
1.000000000
1.000000000

dv> gradient_colour_04
1x1x3 array of float, bsq format [12 bytes]
0.0000000000
0.0000000000
1.000000000

dv> gradient_colour_05
1x1x3 array of float, bsq format [12 bytes]
1.000000000
0.0000000000
1.000000000

dv> gradient_colour_06
1x1x3 array of float, bsq format [12 bytes]
1.000000000
0.0000000000
0.0000000000

dv> g = buildgradient(1, gradient_colour_00, 10922, gradient_colour_01, 21844, gradient_colour_02, 32768,
    gradient_colour_03, 43688, gradient_colour_04,  54610, gradient_colour_05, 65536, gradient_colour_06)
Generating a gradient using 7 colours and 3 channels.
65536x1x3 array of float, bsq format [786,432 bytes]

Gradient-02-HW.PNG

The 'Vegetation Index Single Scale' colour gradient from The Mirror's Surface Breaks:

dv> gradient_colour_00
1x1x3 array of float, bsq format [12 bytes]
0.5000076294
0.5000076294
0.5000076294

dv> gradient_colour_01
1x1x3 array of float, bsq format [12 bytes]
0.1250019073
0.1250019073
0.1250019073

dv> gradient_colour_02
1x1x3 array of float, bsq format [12 bytes]
0.3058823943
0.2039216012
0.1450980008

dv> gradient_colour_03
1x1x3 array of float, bsq format [12 bytes]
0.5411764979
0.5411764979
0.03921569139

dv> gradient_colour_04
1x1x3 array of float, bsq format [12 bytes]
0.0000000000
1.000000000
0.0000000000

dv> g = buildgradient(1, gradient_colour_00, 16384, gradient_colour_01, 21299, gradient_colour_02, 41288,
    gradient_colour_03, 65536, gradient_colour_04)
Generating a gradient using 5 colours and 3 channels.
65536x1x3 array of float, bsq format [786,432 bytes]

Gradient-03-VISS.PNG

The 'Classic Thermograph' colour gradient from The Mirror's Surface Breaks:

dv> gradient_colour_00
1x1x3 array of float, bsq format [12 bytes]
0.0000000000
0.0000000000
0.0000000000

dv> gradient_colour_01
1x1x3 array of float, bsq format [12 bytes]
1.000000000
0.0000000000
1.000000000

dv> gradient_colour_02
1x1x3 array of float, bsq format [12 bytes]
0.0000000000
0.0000000000
1.000000000

dv> gradient_colour_03
1x1x3 array of float, bsq format [12 bytes]
0.0000000000
1.000000000
1.000000000

dv> gradient_colour_04
1x1x3 array of float, bsq format [12 bytes]
0.0000000000
1.000000000
0.0000000000

dv> gradient_colour_05
1x1x3 array of float, bsq format [12 bytes]
1.000000000
1.000000000
0.0000000000

dv> gradient_colour_06
1x1x3 array of float, bsq format [12 bytes]
1.000000000
0.0000000000
0.0000000000

dv> gradient_colour_07
1x1x3 array of float, bsq format [12 bytes]
1.000000000
1.000000000
1.000000000

dv> g = buildgradient(1, gradient_colour_00, 6554, gradient_colour_01, 16384, gradient_colour_02, 26214,
    gradient_colour_03, 36045, gradient_colour_04, 45875, gradient_colour_05, 52429, gradient_colour_06, 65536, gradient_colour_07)
Generating a gradient using 8 colours and 3 channels.
65536x1x3 array of float, bsq format [786,432 bytes]

Gradient-04-CT.PNG

The 'Modern Thermograph 3' colour gradient from The Mirror's Surface Breaks:

dv> gradient_colour_00
1x1x3 array of float, bsq format [12 bytes]
0.0000000000
0.0000000000
0.0000000000

dv> gradient_colour_01
1x1x3 array of float, bsq format [12 bytes]
0.03921569139
0.0000000000
0.6980391741

dv> gradient_colour_02
1x1x3 array of float, bsq format [12 bytes]
1.000000000
0.0000000000
0.0000000000

dv> gradient_colour_03
1x1x3 array of float, bsq format [12 bytes]
1.000000000
0.9882352948
0.0000000000

dv> gradient_colour_04
1x1x3 array of float, bsq format [12 bytes]
1.000000000
1.000000000
1.000000000

dv> g = buildgradient(1, gradient_colour_00, 13763, gradient_colour_01, 27525, gradient_colour_02, 58327,
    gradient_colour_03, 65536, gradient_colour_04)
Generating a gradient using 5 colours and 3 channels.
65536x1x3 array of float, bsq format [786,432 bytes]

Gradient-05-MT3.PNG


DavinciWiki Mini-Nav Bar

Contents


Contact Developers

  • davinci-dev [AT] mars.asu.edu

All other topics

  • See navigation on the left

Related Functions

Recent Library Changes

Created On: 07-16-2012
Modified On: 05-02-2013

Personal tools