Many images we work with in the Style dialog can be made more comprehensible by changing contrast and applying hill shading while leaving the colors in a grayscale range, for example, as shown in the Example: Autocontrast and Hill Shading Images using Style topic. In addition we can also achieve differentiating visual effects by coloring the pixels using a palette. Palettes use a single, grayscale color value in a pixel as a lookup index to pick a specific RGB color out of a specified collection of RGB colors. The collection of RGB colors from which a specific color is picked is called a palette. This topic provides a tutorial introduction to palettes.
See also the palette images and comments in the Notes to the Style: Autocontrast topic.
We will utilize the same image, providing terrain elevation data in a section of the state of Florida, in the US, that was used in the Example: Autocontrast and Hill Shading Images using Style topic.
The default image is dark and poorly differentiated. We open the Style pane and then manipulate the image to provide better contrast before we apply a palette.
In the source box we choose Channel 0. We enter 2 for the number of Breaks and then press the Tally button. Double-click into the lower color box in the intervals list and change it to white. Set the Fill rule to Interpolate and press Update Style
The result is a grayscale image, seen above zoomed out a bit to show more of the terrain, that has reasonable contrast as the values from about 0 to about 92 are assigned to a continuum of grayscale colors from black to white, that is, from 0 to 255.
Applying a palette is easy: We choose the number of Breaks we want (one more than the number of intervals we desire), press Tally to create intervals and then we press the palette button to choose a palette. If we want a different palette than Altitude we first choose that using the pull down menu on the Altitude button and then we press the button.
We will apply a palette to the image using ten intervals:
We enter 11 into the Breaks box and then press Tally.
We press the palette button and then in the Classic sub-menu we choose the Altitude palette..
That loads the color values in the intervals list with the colors from the Altitude palette.
As can be seen from the above the Altitude palette provides a fairly typical set of colors that are assigned to various elevations in maps, with elevations lower down being more green and those higher being brown, gray or ultimately, white.
The Fill box provides various options for how color values found in the data should be assigned to a palette color if the color value in the data does not precisely match one of the numbers in the palette. The interpolate fill rule is still active from when we set the contrast.
The default, interpolate option interpolates the range between two colors in the palette. For example, if we have colors for the break at about 27 and a different color for the break at 36, if we have a data value of 31 the color assigned to that pixels will be about half way between whatever colors in the palette are assigned to 27 and 36.
Press Update Style to apply the palette.
The result is a pleasing rendering. It shows how we can bring out features by using different colors for different elevation values. If we would like to adjust the palette that is easy to do.
We can Ctrl-click one interval bound and then Shift-Ctrl-click another to select all intervals between. We can then right-click onto one of the selected color wells and choose one of the commands from the context menu. For example, we can click reverse to reverse the swath of colors from green to brown.
Press Update Style.
The result is a variation on the palette that reversed the group of colors between brown and green without changing the application of the very light colors.
If we would like to choose an entirely different palette that is easy to do as well. We pause to click into the intervals list to move the focus there, and then we do a Shift-Ctrl-A to deselect all intervals, to clean up the display.
We click the palette button and choose the Color Brewer menu.
The Color Brewer menu includes many palettes that are named beginning with CB. These are cool collections of colors created by Cynthia Brewer at Penn State that work very well together in various settings. We choose the CB Set C palette.
Choosing the CB Set C palette applies it to the color wells in our intervals list. We press Update Style to apply that arrangement to the image.
It is easy to instantaneously change color palettes. Note that by applying a palette we are only changing the style of how the image is displayed. We are not changing the data.
Different palettes can give completely different visual effects, allowing us to choose what features we would like to emphasize by a clever choice of colors or palette. The above illustration uses the CB Paired palette while the illustration below uses the CB Spectral palette.
Since we are only changing the style of display, a property of the image and not the data, we can Copy the Florida image component (just the image component and not the table) and then Paste it a few times to create additional Florida 2, Florida 3 and Florida 4 images. Being copies of the original Florida image these all will also take their data from the same table.
We can then open each image in turn and launch the Edit - Style dialog to change the palette used by that image.
Above we see all four images open in undocked windows, each one using different Style settings.
Once we use Style to assign a palette to an image that palette is stored in JSON format in the StylePixel property of the image. We can create, delete, copy, paste and otherwise edit that property.
Suppose we copy the Florida image and then paste it in the Project pane to create a Florida 5 image as seen above. The pasted copy of course retains the same style that the original image used.
A quick way to delete all Style information is to open the image's properties and to delete the StylePixel property.
In the Project pane we right-click onto the Florida 5 image and choose Properties In the properties dialog we Ctrl-click on the StylePixel property to select that row and then we press the Delete button.
The property disappears and we press OK.
The Florida 5 image now shows the unstyled appearance the image had at the very beginning of this topic.
An easy way to restore style is to simply copy the StylePixel property's value from one of the other Florida images we created in this topic and to then paste that value into a newly-created StylePixel property in the Florida 5 image.
We will right-click onto the Florida 3 image in the Project pane and choose Properties.
In the properties dialog for the Florida 3 image, we right-click into the value cell for the StylePixel property and then we choose Copy in the context menu. We press Cancel to close the properties dialog.
Next, we right-click onto the Florida 5 image in the Project pane and choose Properties.
In the properties dialog for the Florida 5 image we double-click into the name cell for the * New row to add a new property.
We enter the name StylePixel and press Enter.
We name the new property StylePixel.
We Right-click into the value cell for our newly-created StylePixel property and choose Paste from the context menu. That will paste the copied value into the cell.
We click OK to close the dialog, saving the new values into the properties for the Florida 5 image.
Like magic, the Florida 5 image has the style settings applied which we copied from the Florida 3 image's properties and pasted into the Florida 5 image's properties.
We can get values from the Properties dialog of an image, or we can get it from the mfd_meta system data table. Properties values for all images, like property values for all other components, are stored in the mfd_meta table. We can exploit that to copy and paste JSON values for StylePixel from one compatible image to another.
For example, we can open the mfd_meta table in the Project used for this topic and use Page Down or scrolling or Ctrl-F to find the records giving StylePIxel for Florida 5, as seen above.
We right-click onto the Value cell for the StylePixel property for the Florida 4 image and we choose Copy from the context menu. That copies the JSON text string from that cell onto the Windows clipboard.
Next we right-click onto the Value cell for the StylePixel property for the Florida 5 image and choose Paste from the context menu.
That pastes the JSON text string we copied from the Florida 4 record into the cell for the Florida 5 record.
Right away, again like magic, the Florida 5 image takes on the styling that we copied and pasted from the Florida 4 image.
Compatible images - Copying and pasting JSON strings for the StylePixel property is great, but we should keep in mind that the numbers those styles use should be reasonably compatible with the images into which they are pasted. If we used Style for an image where values were 0 to 50 for the intervals those Styles will not be very effective for an image where data values are 500 to 5000.
Palette Colors are RGB Colors - Manifold palettes, for now, provide a roster of RGB colors. In the future that might be extended to RGBA colors.
Style: Channels and Outputs Tutorial
Style: Invisible Pixels
Style: Contouring using Colors
Style: Hill Shading
Example: Change the Contrast of an Image - In this example we use the Style dialog 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: Assign Channels - 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.
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 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 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.