Several new commands in the ColorTools
package allow collections of colors (palettes) to be extended or reduced. Such collections of colors can be easily used in the shading of multiple plot objects.
This section illustrates the functionality by extracting the colors from an external image file, reducing the full collection of its colors to a small representative list, extending that collection with additional colors, sorting that larger collection to increase visual distinction, and then using the final collection of colors as the basis of a new plotting color palette.
In addition, we demonstrate a new way to visualize collections of colors.
>
|
|
We can begin by reading an image file into the Maple session. The resulting Array structure is interpreted by Maple as an image, and can be viewed or embedded directly in the current Worksheet or Document.
>
|
|
>
|
|
The colors can be extracted from the image. The ColorsFromImage command can extract from the image a list of Color
objects as a format understood by the ColorTools package.
>
|
|
Below is a small selection of those colors.
| (2.2) |
The new SpatterPlot
and SpatterPlot3d commands of Maple 18 allow us to visualize the distribution of colors in the image in either two or three dimensions. These new commands also allow the colors to be plotted in various color spaces
.
Here are the colors from the image, plotted in terms of the RGB and Lab color spaces.
>
|
|
Using the ReducePalette
command, the list of colors from the image can be reduced to a much smaller, but still representative, list of colors.
>
|
|
| (2.3) |
The small list of representative colors can be further expanded to produce a larger palette.
>
|
|
| (2.5) |
The above list of colors is not ordered in a manner suitable for plotting multiple curves, since the colors near the start of the list are too close together. Notice that the first and fourth colors are not readily distinguishable.
The expanded list of colors can be sorted by the new SortPalette command, so that the earlier colors are farther apart. This can make the final list of colors more suitable as a palette for plotting multiple curves, since the earlier colors will be more visually distinguishable in the given color space.
| (2.6) |
>
|
|
To set a new color palette for plotting, pass the above final color list to the setcolors
command. This allows the colors to be used for shading multiple curves without requiring any reference to the color list within the plotting commands.
The Color
object is just one of several formats to denote color that the setcolors command supports.
>
|
|
>
|
|
|
>
|
|
|
>
|
|
|
|
|
The extended palette can be plotted together with the original full list of colors from the image.
>
|
|