Example: Using the Assign Channels Button

btn_style_assign_channels.png

The Assign Channels button in the Style panel 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.   The Example: Assign Channels topic shows how to assign channels individually.

 

See also the Style: Channels and Outputs Tutorial topic.

 

Computer monitors use three color elements, red, green and blue, per pixel.  These are called display outputs.   Computer images intended to be displayed in full color will often provide three channels per pixel, that is, three numbers in the image file for each pixel, with the three channels numbered channel 0, channel 1 and channel 2.   In most image formats, channel 0 is intended to provide blue display output values, channel 1 is for green and channel 2 is for red.   

 

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 panel allows us to specify how those channels should be assigned to red, green and blue display outputs.

 

The usual description of color images as RGB images is intended to capture the idea that the image data contains three channels per pixel, with one channel for Red, one channel for Blue and one channel for Green; however, if we look at the actual ordering of the numbers within the computer file we see that they are in 0, 1, 2 order and in that order are assigned to Blue, Green, and Red.    The casual phrase "RGB image" thus really means a "channel 2, 1, 0, image" in terms of how the channels are numbered.   Many programmers who think of images in the order in which their channels appear in data storage would refer to such images as "BGR images."

 

When we work with individual channels to manipulate the data they contain or when we create false-color images that map various data from many-channel images into three display outputs, even if we are not doing any programming we may need to be aware of the actual order of channels in a particular image, and we must be ready to change the order of channels from BGR to RGB or to other orders.

 

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.   For now, we will use the Assign Channels button to change the interpretation of data within the image, without actually changing the data itself.

 

This topic shows step-by-step examples.   The sample image we use, Leonardo's portrait of Ginevra de' Benci, is the same image used in the Example: Change the Contrast of an Image topic.

 

il_style_image_bgr01_01.png

We open the image and then use the Style panel.

 

il_style_image_bgr01_02.pngil_style_image_bgr01_02a.png

 

The panel presents the list of display outputs in expected red, green and blue order, but if we look closely we see that the channels are assigned in BGR order, the default for most "RGB" color images.    The first channel in the data, Channel 0, is assigned to B, Channel 1 to G and Channel 2 to R.  Those are the default assignments used by most image formats that utilize three color channels.

 

btn_style_assign_channels.pngWe can change those assignments with the Assign Channels button by clicking on the button and picking the arrangement desired from the pull down menu.

 

il_style_image_bgr01_03.pngil_style_image_bgr01_03a.png

 

For example, we can choose RGB.  Immediately the assignment of data channels to output colors is reversed, so that the first channel in the data, Channel 0, is assigned to R, Channel 1 to G and Channel 2 to B.     We press Update Style to apply the change.

 

il_style_image_bgr01_04.png

 

When we do so we see the effect of swapping the channels used for B and R.   Portions of the image that originally were bluish, such as the distant landscape seen in the middle right of the painting, are now reddish and vice versa.

 

Continuing on we try the single channel settings in the pull down menu.   These take one of the data channels and apply it to all three B, G and R outputs.  When all three outputs have the same value the result is a grayscale image.

 

il_style_image_bgr01_05.pngil_style_image_bgr01_05a.png

 

Choosing Channel 0 in the pull down menu applies the values from Channel 0 to all three B, G and R outputs.  The other two channels contain values that range from 0 to 255 but Channel 0 contains value that range only from 0 to 238.  Press Update Style to update the image.

 

il_style_image_bgr01_06.png

 

Data Channel 0 in this image carries information intended for the Blue or B output.  What we see above is a grayscale rendition of the blue channel.

 

il_style_image_bgr01_07.pngil_style_image_bgr01_07a.png

 

Choosing Channel 1 applies the values from Channel 1 to all three B, G and R outputs.   Press Update Style to update the image.

 

il_style_image_bgr01_08.png

 

Data Channel 1 in this image carries information intended for the Green or G output.  What we see above is a grayscale rendition of the green channel.

 

il_style_image_bgr01_09.pngil_style_image_bgr01_09a.png

 

Choosing Channel 2 applies the values from Channel 2 to all three B, G and R outputs.   Press Update Style to update the image.

 

il_style_image_bgr01_10.png

 

Data Channel 2 in this image carries information intended for the Red or R output.  What we see above is a grayscale rendition of the red channel.

 

The above changes to style settings do not make any changes to the data stored in the table from which the image is created.  They are all just style settings that change how that data is displayed.     We can demonstrate that by going back to the original style settings for how the channels are assigned.

 

il_style_image_bgr01_11.pngil_style_image_bgr01_11a.png

 

We choose BGR in the pull down menu.   That re-assigns the original default settings of Channel 0 for B, Channel 1 for G and Channel 2 for R.     Press Update Style to update the image.

 

il_style_image_bgr01_12.png

We again see the original image.

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 panel to change the contrast of an image.

 

Example: Assign Channels - How to use the Style panel 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.

 

Example: Display an NAIP Four Band Image as Color Infrared (CIR) - How to use the Style panel 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 panel 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 panel 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 panel 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 panel to rearrange the order of channels within the data.