Example: Using the Assign Channels Button


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.   


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.  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.



We open the image and then use the Style panel.




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.




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.




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.




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.




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.




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




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.




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




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.




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.



We again see the original image.


See Also



Images and Channels


Palette Images




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.