Edit Classification Images
Lesson content
Lesson 1 of 1
Edit Classification Images
In this quick guide, you will:
- •
Open and display a Sentinel-2 multispectral image and classification image. * •
Use the Edit Classification Image tool to fix misclassified pixels in a classification image.
Sample Data
Download sample data below. Then extract the contents of the .zip file to a local directory.
[Sentinel2_LandCoverClassification.zip
1.7 GB
DownloadArrow down with horizontal line beneath it](assets/Sentinel2_LandCoverClassification.zip)
Background
Initial supervised classification results nearly always contain misclassified pixels. While you can alleviate most misclassification issues by experimenting with supervised classifier settings and/or modifying training data, the final classification image may still need further editing.
The Edit Classification Image tool is best used for editing small areas when you know that pixels were assigned to the wrong class. For example, you may have ground-truth data that verifies that a group of pixels belongs to a known class. Or, you may be certain of the actual classes by viewing a true-color or color-infrared image of the area.
Let's look at an example.
Open and Display Sentinel-2 Images
- 1
Select File > Open from the Menu bar. An Open dialog appears. 2. 2
Go to the directory where you saved the sample data. 3. 3
Use the Ctrl key to multi-select the files Sentinel2_LayerStack_Montana.dat and Sentinel2_Montana_Classes.dat (in that order). 4. 4
Click Open. The images are added to the Layer Manager and displayed in the Image window. The first displayed image is an ENVI classification raster created from a Minimum Distance supervised classifier. Refer to the Perform a Supervised Classification quick guide for the steps taken to create this image.

- 5
In the Layer Manager, uncheck and check the Sentinel2_Montana_Classes.dat layer on and off to compare it with the Sentinel-2 multispectral image.
Throughout the scene, you will notice areas that are incorrectly classified. An example is the mountainous region on the right side of the image, which contains an abundance of "Water" (blue) and "Wetland" (cyan) class pixels. In reality, the mountains do not contain large bodies of water or wetland areas. The classifier mistook shadowed areas as "Water." It also confused "Wetland" with "Grass/Shrub" (light green).
![]()
You have some options for mitigating class confusion:
- •
When collecting training data, ensure that the "Water" and "Wetland" ROIs only contain those land-cover types and nothing else. Also, it may be worth collecting more training samples for these classes. See the Collect Classification Training Data from Image Spectra quick guide for more information. * •
Create a separate "Shadow" class, and collect training data from pixels that are in shadow. However, "Shadow" isn't a true land-cover type. Pixels that are shadowed by terrain are other land-cover types in reality.
Instead of modifying training data or creating a new class for shadowed pixels, you can use the Edit Classification Image tool to reassign classes.
Edit Classes
When using the Edit Classification Image tool, you can control exactly where class edits occur. Changing one class to another does not apply to the entire image, only the areas you specify.
For this exercise, let's focus on editing classes in the mountainous region only.
- 1
In the Layer Manager, select Sentinel2_Montana_Classes.dat to make it the active layer.

- 2
Click the Edit Classification Image button in the Toolbar, as shown below. You can also start the tool by expanding the Classification > Post Classification folders in the Toolbox and double-clicking Edit Classification Image.

The Edit Classification Imagedialog appears, and a new "Class Edit" layer is added to the Layer Manager. You will make edits to this layer instead of the original classification image. This is to prevent you from overwriting the original image.
- 3
In the Layer Manager, uncheck Sentinel2_Montana_Classes.dat (the original classification image) to hide it. 2. 4
Uncheck and check the Class Edit layer to compare it with the Sentinel-2 image. 3. 5
For this example, let's change "Water" pixels to a different class in the mountainous region. Some lakes do exist in this area, so you must identify the real water bodies. Pan and zoom to the mountainous region shown below, which is located on the right side of the image. You cannot really tell whether the dark pixels in the Sentinel-2 image are shadow or water.

A base map can help verify the locations of lakes.
- 6
From the ENVI Menu bar, select Views > Reference Map Link. The Reference Map Link dialog appears. The cyan-colored dot in the middle corresponds to the center of the Sentinel-2 image. The example below shows three lakes that exist in the area, according to the base map. They are circled red in the Sentinel-2 image:

- 7
Keep the Reference Map Link dialog open for the rest of the quick guide. Move it out of the way if necessary. 2. 8
In the Layer Manager, select the Class Edit layer to redisplay it. 3. 9
In the Edit Classification Image dialog, click the From: drop-down list and select Water. 4. 10
Click the To: drop-down list and select a different class such as Grass/Shrub, Tree Cover, Barren, or Ice/Snow. 5. 11
Notice that Shape is the default setting in the Edit Classification Image. Polygon is the selected shape. 6. 12
Draw a polygon around some blue "Water" pixels. Double-click to complete the polygon. Those pixels change to the land-cover type that you selected.
The following video covers these steps and provides some tips to facilitate editing classes.

Video Player is loading.
Play Video
Play
Loaded: 0%
0:00
Remaining Time --:-
1x
Playback Rate 1x
- 2x
- 1.75x
- 1.5x
- 1.25x
- 1x, selected
- 0.75x
- 0.5x
- 0.25x
Captions
- captions off, selected
- English
Picture-in-PictureFullscreen
Mute
This is a modal window.
- 13
Select different From: and To: classes in the Edit Classification Image dialog, then draw polygons around other pixels whose classes need reassignment. For this exercise, you do not need to edit the entire image because it is so large. The point is to become familiar with the process for editing classes.
Also, you can use the Paint option to edit individual pixels or small groups of pixels, instead of drawing polygons. 2. 14
When you are finished editing, right-click on the Class Edit layer and select Save As. The Save Class Edits dialog appears. 3. 15
Set the Remove empty classes? option to No. Your image does not have any empty classes. 4. 16
Enter an output file name of Sentinel2_Classes_Edited.dat and click OK. 5. 17
This concludes the exercise.
In summary, you can use the Edit Classification Image tool to easily reassign pixels from one or more classes to another. In general, it is not recommended to edit large portions of a classification image because you are essentially creating "new" data. It is best to let a supervised classifier assign pixels to predefined classes, while you only edit small areas if you are certain of the target classes.
Additional Resources
- •
Perform a Supervised Classification quick guide
Your input is important to us, please take a few moments to fill out ourQuick Guide Feedback(opens in a new tab)form.
© 2024 NV5 Geospatial Solutions, Inc. This information is not subject to the controls of the International Traffic in Arms Regulations (ITAR) or the Export Administration Regulations (EAR).
