Use the Raster Color Slices tool to select data ranges and colors to highlight areas of an image. You can save the color slices visualization to a classification or to a shapefile.

Click on any of the following links for details:

You can also write a script to define color slices using the ColorSliceClassification task. Use the GetColorSlices task to open density slice range (DSR) files and to retrieve their data ranges and colors. Use the ExportColorSlices task to define your own color slices and ranges, and to export them to a DSR file.

Create a Raster Color Slice


  1. Generate raster color slices using one of the following:

    • In the Layer Manager, right-click the raster name and select New Raster Color Slice.
    • In the Data Manager, right-click a band and select Load Raster Color Slice.
    • From the Toolbox, select Classification > Raster Color Slices.
  2. Select the input file and band in the Data Selection dialog, then click OK.The Edit Raster Color Slices dialog appears. The following default settings are used for the histogram; you can change them as needed, described in Change Default Color Slices Settings:

    • Number of slices = 16
    • Color table = Rainbow
    • Minimum and maximum data ranges, calculated from the input image
  3. Click OK to create the raster color slices. ENVI adds a Raster Color Slice folder to the Layer Manager and loads the layer into the Image window. Click OK again in the Edit Raster Color Slices dialog to keep the layer in the Layer Manager and close the dialog; if you click Cancel, the layer will be removed.

To hide or show raster color slices in the Image window:

  • Disable or enable the check box for a slice in the Layer Manager.
  • To hide all raster color slices, right-click the Slices folder and select Hide All Color Slices. To show all color slices again, right-click and select Show All Color Slices.
  • You can also hide all color slices by disabling the check box for Raster Color Slice layer in the Layer Manager. This leaves the state of individually hidden raster color slices unchanged (for example, the check box for a hidden class is not enabled again) so when you show the raster color slices layer again, the previously hidden color slice remains hidden.

Edit Color Slices


To change the settings for a raster color slice, right-click the Slices folder in the Layer Manager and select Edit Color Slices. The Edit Raster Color Slices dialog appears. To select a color slice, click the table row to highlight it in the histogram, or click the color slice in the histogram to select it in the table row.

You can save the colors and data ranges you define for raster color slices. You can restore saved raster color slices on the same raster, or on another raster of the same size.

Plot controls:

  • Enable the Plot Controls check box, click in the histogram, and use the mouse wheel to zoom in and out. Disable the check box again to re-enable editing functions.
  • Enable the Plot Controls check box, then click and hold on a curve in the plot to show the X-Y line crosshair. As you move the cursor over the curve, the crosshair snaps to the closest data point. The X and Y values of the point appear below the plot.
  • Enter Histogram Min and Max values in the fields provided to zoom to a specific range.
  • To reset the plot range to its original settings, click Reset.

To edit the data ranges:

  • Click on a color slice in the histogram, then click and drag the right or left edges of the color to resize the minimum or maximum data range for that slice.
  • Click and drag on a color slice in the histogram to redefine its range.
  • Enter a new Slice Min or Slice Max value for the slice in the table.

    When data ranges are in floating-point data type, they can have overlap between the Slice Max of one range and the Slice Min of the next range, as shown below:

    When such overlap occurs, the data is included in the later range. In the image above, the data for pixel value 20.617036 will be contained in color slice 2 (the later range), the data for pixel value 21.538165 will be contained in color slice 3, and so on.

To change colors:

  • To reverse the order of the color gradient, click the Change Color Table button. In the Change Color Table dialog that appears, click the Reverse button.

  • To apply a different pre-defined IDL color table to all data ranges, click the Change Color Table button. In the Change Color Table dialog that appears, select a color table from the drop-down list.

To refine color slices:

  • To delete a color slice, select it in the histogram or from the table row and click the Remove Color Slices button. You can use Shift-click to select multiple sequential rows to delete.
  • To clear all color slices, click the Clear Color Slices button .
  • To manually define individual color slices, click the Add Color Slice button to add a data range to the table and the histogram. Unless you clicked Clear Color Slices before adding the color slice, the new slice is added to the end of the data ranges in the table and the histogram.
  • To edit a particular color, click the color in the table row and choose a different color from the dialog that appears.

To save and restore raster color slices:

  • To save the raster color slices to a file, click the Save Color Slices to File button and enter a filename.
  • To open a previously saved raster color slices file, click the Restore Color Slices from File button and select the file.

Change Default Color Slices Settings


To edit the default settings for raster color slices, click the New Default Color Slices button in the Edit Raster Color Slices dialog. The Default Raster Color Slices dialog appears. Change the settings as needed, then click OK.

  • Num Slices sets the number of color slices to apply to the image.
  • Colors provides a drop-down list of predefined IDL color tables.
  • Reverse reverses the order of the color gradient.
  • By Min/Max allows you to define the color slices with minimum and maximum data ranges in the Data Min and Data Max fields.
  • By Min/Slice Size allows you to define the minimum data range and slice size in the Data Min and Slice Size fields.
  • To define your own color table, select RGB, HLS, HSV, or CMY from the drop-down list.
  • Enable the check box next to the slider bar of the color space element you want to change. The two remaining sliders represent horizontal and vertical axes of the currently displayed color space and remain constant; only the slider with the enabled check box can change the current color space.
  • Move the slider bars for an element to adjust the values of the color space.
  • In the color space window, click and drag the end points of the interpolation line to change the current color table. The color table will contain the colors that fall beneath this line.

Export Raster Color Slices


You can export the raster color slices to a classification image or to a shapefile.

  • To save a displayed color slices to a classification image, right-click the Slices folder for the layer to export and select Export Color Slices > Class Image. This option is also available from the Export drop-down button in the Edit Raster Color Slices dialog. The saved file is added to the Data Manager for you to load. Once you create a classification image, you can Legend Annotation from the Annotations drop-down menu in the toolbar to display a classification legend.
  • To save the displayed color slices to a shapefile, right-click the Slices folder for the layer to export and select Export Color Slices > Shapefile. This option is also available from the Export drop-down button in the Edit Raster Color Slices dialog. The saved file is added to the Data Manager.

Calculate Class Statistics


You can calculate class statistics for the color slices, including:.

  • Pixel count and percentage per class.
  • Basic statistics (minimum, maximum, mean, and standard deviation) for single- or multi-band images.
  • Histograms (frequency distributions) for single- or multi-band images.

For details, see Class Statistics.

See Also


Classification, Classification Tools