Example: Use the BGR Button to Assign Channels

The BGR button in the Edit - Style dialog for images allows us to assign channels in the data to B, G and R outputs, that is, the Blue, Green and Red outputs, that create the displayed image, using BGR, RGB or Grayscale ordering.

 

Images composed of three colors, as most computer images are, use three channels numbered channel 0, channel 1 and channel 2.   In most formats, channel 0 is intended to provide blue display output values, channel 1 is for green and channel 2 is for 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.

 

This example uses the same sample image, Leonardo's portrait of Ginevra de' Benci, as the Example: Change the Contrast of an Image topic.

 

il_style_image_bgr01_01.png

We open the image and then choose Edit - Style to launch the Style dialog.

 

il_style_image_bgr01_02.png

 

The dialog opens by default with BGR settings, that is, assigning the first channel in the data, Channel 0, to B, Channel 1 to G and Channel 2 to R.  Those are the default assignments used for most images in computing that utilize three color channels.

 

il_style_image_bgr01_03.png

 

We choose RGB and then press the button, now captioned RGB.   Immediately as we do 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 to update the intervals pane, and then we press Apply to update the image.

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 Grayscale settings for the button.   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.png

 

Choosing Grayscale 0 and pressing the Grayscale 0 button 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 to update the intervals and then press Apply 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.png

 

Choosing Grayscale 1 and pressing the Grayscale 1 button applies the values from channel 1 to all three B, G and R outputs.     Press Update and then press Apply 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.png

 

Choosing Grayscale 2 and pressing the Grayscale 2 button applies the values from channel 2 to all three B, G and R outputs.     Press Update and then press Apply to update the image.

il_style_image_bgr01_10.png

Data channel 1 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.png

 

We choose BGR in the pull down menu and then we press the BGR button.   That re-assigns the original default settings of channel 0 for B, channel 1 for G and channel 2 for R.     Press Apply to update the image.

il_style_image_bgr01_12.png

We now see the original image.

 

See Also

Images

 

Images and Channels

 

Palette Images

 

Style

 

Style: Presenting Images

 

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

 

Example: Assign Channels using Source - The Source control in the Style dialog for images assigns channels to display outputs such as R, G, B or A.  .  This topic shows examples of using Source and the visual results.

 

Example: Set Image Transparency using Alpha - The A row in the Style dialog 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 Edit - Style dialog 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 Edit - Style dialog 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.