Example: Assign Channels

This topic shows how to use the Style pane for images to assign channels to display outputs such as R, G, B or A.  This topic shows examples of channel combinations and the visual results.

 

Different image formats utilize different arrangements of channels within the actual image data.  Some have the red channel first, while other arrangements have the blue channel first.  No matter what channel ordering is used within the data, Manifold's Style pane allows us to specify how those channels should be assigned to red, green and blue display outputs.

 

The Assign Channels button makes such typical reassignments of channels a one-click operation.  Using the Assign Channels button does not  change the order of data channels within the actual image.   It simply reassigns how the data should be interpreted for display purposes.   If we want to change the actual order of data in the image, we should use the technique illustrated in the Example: Rearrange Channels using an Expression  topic.   In this topic, we will use the Assign Channels button to change the interpretation of data within the image, without actually changing the data itself.

 

This example continues using the same example data as the Example: Using the Assign Channels Button topic.   Although the example image is a painting, these same techniques are utilized to assign channels in spatial data applications, for example, when building a false color image from multispectral satellite sensing data.

 

See also the Style: Channels and Outputs Tutorial topic.

 

 

We open the sample ginevra image, a portrait of Ginevra de' Benci by Leonardo.   We then choose the Style pane and then we click on the right side of the big style properties button.

 

For RGB images by default the Style pane shows the default assignment of channels 2, 1 and 1 to the usual RGB outputs. The A, or alpha transparency channel has a fixed value of 0 since the original image is an RGB image without a fourth, A, channel.

 

 

Channel 0 feeds the Blue or B output, Channel 1 goes to the Green or G output and Channel 2 drives to the Red or R output.   We will change that.    We begin by clicking the Channel 2 cell, to choose a different channel for the R output.

 

 When the row cursor is already on a cell, we can open that cell for editing by simply clicking it.   If the cursor is not on a cell, we can open the cell for editing by double-clicking it.  

 

 

In the pull down menu that pops open we choose Channel 1 to use that channel for the R output.

 

 

The channels list updates to show that the R display output will be driven by the values found in Channel 1.   We press Update Style to commit the changes.

 

 

The drawing immediately updates.  It looks less red and more gray because the content for the red display output is being driven by values in the channel that is also driving the green display output.    When similar values are used to drive the display outputs, more gray tones are the result.

 

Let us now use Channel 0 for the R display output.

 

 

To do that, we double-click into the channel cell for the R row and in the pull down menu we choose Channel 0.  The pane updates the channels list to show that the R display output will take its values from Channel 0.    We press Update Style.

 

 

The drawing updates so that regions where the channel originally intended to drive the Blue display output, Channel 0, were bright now appear in magenta tones that are a blend of blue and red,  in regions where the Red display output, using Channel 0, is also bright.

 

 

We click into the channel cell for G output.

 

 

In the pull down menu we choose Channel 0 and then press Update Style.  Now all three display outputs, R, G and B, are driven by the same channel.

 

 

The result is a grayscale image that is a grayscale rendition of the values in channel 0.   When all pixels in an RGB image are the same value the result is a gray color.

Variations

We will now consider variations in how outputs are fed by channels or by values.

 

 

In the above illustration we have assigned Channel 0 to R, Channel 2 to G and Channel 1 to B.   The Channel 0 set of intensities that originally were intended to drive the Blue output are now controlling Red, the intensities originally intended for Red, Channel 2, are now driving Green, and the original channel for Green, Channel 1, is now driving Blue.  Press Update Style.

 

 

The result is an otherworldly image, with color tones somewhat reminiscent of false color satellite imagery built from infrared spectra.

 

 

We can restore the original channel assignments by choosing Channel 2 for R, Channel 1 for G, and Channel 0 for B.  We press Update Style.

 

 

The image is now back to using the intended channels to drive each display output.    That illustrates how shuffling channel assignments does not change the original data, which continues to be stored unmodified in tiles in the table from which the image is created.

Fixed Values for Outputs

So far we have chosen a channel to drive a given R, G, or B output.   We can also specify a fixed value to use for all pixels in a given display output.

 

 

We click on the channel cell for the first, R, row.  

 

 

In the pull down menu we choose Value.

 

 

We double-click into the 0 cell next to Value and specify a value of 125 and press Update Style.  This applies the same value, that is the display intensity, of 125 in all pixels for the Red display output.

 

 

A Value of 125 is approximately half-way from no red, 0, to full intensity, 255, for the Red output.   The net effect is like replacing the red display output with a sheet of red plastic that is half-transparent.

 

 

A more classic effect is to use a Value of 0 for the Red display output, in effect using only Blue and Green outputs to power the display.   Press Update Style.

 

 

The result is the classic blend of Blue and Green channels, or cyan.

 

We can set a Value of 0 for all display outputs we would like to turn off, so that only one display output is used at a time.

 

 

In the above arrangement we have assigned a Value of 0 to the R and G outputs and we have left the original Channel 0 driving the B output.   Press Update Style.

 

 

This produces an image using only the Blue output.

 

 

We assign a Value of 0 to R and B and we assign the original Channel 1 to G.  Press Update Style.

 

 

This produces an image using only Green channel output.

 

 

We assign a Value of 0 to G and B and we assign the original Channel 2 to R.  Press Update Style.

 

 

This produces an image using only Red channel output.

 

To round out our presentation of how channels combine to create imagery, we will show how Green and Red produce yellow and then how Red and Blue produce magenta.

 

 

We assign a Value of 0 to B and we assign the original Channel 2 to R and the original Channel 1 to G.  Press Update Style.

 

 

This produces an image using only Red and Green outputs, resulting in yellow.

 

 

Finally, we assign a Value of 0 to G and we assign the original Channel 2 to R and the original Channel 0 to B.  Press Update Style.

 

 

This produces an image using only Red and Blue outputs, resulting in magenta.

 

 

Considering the image that uses all channels to drive all three display outputs we can see how various combinations result in the classic presentation of Red, Green and Blue outputs with magenta, yellow and cyan combinations.

 

 

The Alpha Channel

The fourth channel in the image, called an alpha channel, specifies the transparency of each pixel in the image.  

 

 

We start with the example image as seen above.

 

 

The image has R, G, and B channels powered by Channel 2, Channel 1, and Channel 0 respectively.   The A alpha channel uses a Value of 0, meaning all pixels in the channel have zero transparency (or, if we prefer to look at it that way, full opacity).

 

We can change the Value to 125.   That sets the transparency of all pixels to halfway between fully opaque and fully transparent.

 

Press Update Style.

 

 

The result is a much lighter image.   We get that effect because, by default, all images have a virtual background layer that is white color.  When that white color is seen through pixels that are halfway transparent, the effect is an image composed of whiter, much lighter, pixels.

 

 

 

In the Layers pane we can turn off the Background by clicking the on/off box to off.

 

 

 

Instead of a solid white background layer, the background layer uses a checkerboard pattern (as is typical for most graphics editing packages, like PhotoShop) to indicate it is a transparent background.   

 

Setting the A alpha value of each pixel to 125 allows the background checkerboard pattern to show through in an even way throughout the entire image.

Use a Channel to Control Alpha

Using the Value setting for a channel applies the specified value to all pixels in the image.  If we prefer, we can use a channel to drive the alpha channel.

 

 

In the Style pane we choose Channel 1 to control the A alpha channel.   Channel 1 is the same channel that drives the G Green output.     Press Update Style.

 

 

The result is seen at left above.  Pixels where the green channel has a higher value for the pixel are more transparent.    We can compare the increased transparency caused by brighter green values for a pixel by looking at the green values seen in isolation on the right, where only the green channel is used.

 

Where the green channel has brightest values, those near 255, such as in the almost white pixels in the forehead, where R, G and B channels are have values near 255, the near-255 value of Channel 1 for pixels results in nearly transparent pixels.    

 

In contrast, where the green channel has darkest values, those near 0, such as in the darker shadows of the foliage or in the dark brown sash draped around the subject's neck, the near-zero value of Channel 1 for pixels results in nearly opaque pixels.

 

The use of a channel to control alpha transparency can create some spectacular effects, as illustrated in the Knock Out Pixels Using Join and Alpha video.

 

Notes

"RGB" or "BGR"? - The universal slang for RGB images is, of course, "RGB images."  That slang refers to the use of Red, Green and Blue display outputs and does not arise from the literal order of data in the triplets of numbers that specify red data, green data and blue data.  Most users working with RGB images in graphics arts editing do not know and do not care what order channels come in, but when we are extracting data or mixing channels for multichannel remote-sensed images we must care about such technical details.  

 

Almost always the order of data in a triplet of image data numbers for a pixel is that blue comes first, green second and red third.  From a data perspective, the channel ordering is almost always BGR but such images nonetheless are referred to as "RGB" images.  

Downloads

Download the full size ginevra image from the Product Downloads page.

See Also

Images

 

Images and Channels

 

Palette Images

 

Style

 

Style: Images

 

Style: Channels and Outputs Tutorial

 

Style: Autocontrast

 

Style: Palettes

 

Example: How Images use Tiles from Tables - An example showing how an image is made up from data stored in a table in tiles.

 

Example: Create Two Images From One Table - More than one image can show data from the same table, including from the same tile field.

 

Example: An Image using Computed Fields in a Table - How an image can be created from tiles where the data for the tiles is taken from a field that is computed on the fly.

 

Example: Change the Contrast of an Image - In this example we use the Style pane to change the contrast of an image.

 

Example: Using the Assign Channels Button - The Assign Channels button in the Style pane for images allows us to assign channels to the standard three Red, Green, and Blue display outputs using frequently-desired arrangements.   The button provides a short cut way to assign all channels at once instead of doing each channel individually.

 

Example: Display an NAIP Four Band Image as Color Infrared (CIR) - How to use the Style pane for images to re-assign channels in a four band NAIP image to produce a Color Infrared (CIR) image display.

 

Example: Set Image Transparency using Alpha - The A row in the Style pane allows us to specify what transparency we want to apply to the image, either by applying the same value for A for all pixels or by using one of the other channels to also control the A value.

 

Example: Autocontrast and Hill Shading Images using Style - This example shows how the Style pane can hill shade an image using the values of pixels as heights and generating shadows as if the Sun were located at the specified azimuth and altitude.   This capability is used most frequently with raster images to give an impression of three dimensionality in cases where the values of pixels represent terrain elevations.

 

Example: Style Applied to an Image Server Image - Because the Style pane simply changes the way an image is displayed and not the data, it can operate on read-only data served by various web servers such as WMS REST servers.    In this example we look at every detail of creating a data source using an image server and then manipulating the appearance of the display with Style.  We will connect to a WMS server that provides LiDAR data in various forms, including as terrain elevation.

 

SQL Example: Create NDVI Displays - How to create a query that creates an NDVI display from a four-band NAIP image, with tips and tricks on how to copy and paste existing information to get the result we want.

 

Example: Rearrange Channels using an Expression - We use a simple expression in the Transform pane to rearrange the order of channels within the data.