Performing object-based image analysis - PCI Geomatics

Performing object-based image analysis - PCI Geomatics

Performing object-based image analysis - PCI Geomatics
Performing object-based image analysis - PCI Geomatics
Performing object-based image analysis - PCI Geomatics

P Pe er rf fo or rm mi in ng g o ob bj je ec ct t- -b ba as se ed d i im ma ag ge e a an na al ly ys si is s U Us si in ng g O Ob bj je ec ct t A An na al ly ys st t i in n G Ge eo om ma at ti ic ca a F Fo oc cu us s Version 2.0

Performing object-based image analysis - PCI Geomatics

Page iv PCI Geomatics ©2018 PCI Geomatics Enterprises, Inc.® All rights reserved. COPYRIGHT NOTICE Software copyrighted © by PCI Geomatics Enterprises, Inc., 90 Allstate Parkway, Suite 501, Markham, Ontario L3R 6H3, CANADA Telephone number: (905) 764-0614 The Licensed Software contains material that is protected by international Copyright Law and trade secret law, and by international treaty provisions, as well as by the laws of the country in which this software is used.

All rights not granted to Licensee herein are reserved to Licensor. Licensee may not remove any proprietary notice of Licensor from any copy of the Licensed Software.

Performing object-based image analysis - PCI Geomatics

PCI Geomatics Page v C Co on nt te en nt ts s Introduction 7 About Object Analyst 7 Workflow of object-based image analysis 7 Workflow diagram of object-based image analysis 10 Project architecture 11 Region of study, objective, data 13 Region of study 13 Objective 14 Segmentation and attribute calculation 17 Segmentation is key 17 Running Segmentation 19 Viewing the segmentation layer in Attribute Manager 21 Creating a Geomatica project file 22 Attribute Calculation 22 Collecting and editing training sites 27 Training sites 27 Selecting a training vector layer and training field 30 Importing ground-truth points 34 Viewing the updated classes in Attribute Manager 35 Classification 37 Selecting the segmentation file and attribute fields 37 Viewing a classification 39 Accuracy Assessment 43 Evaluating classification accuracy 43 Editing and improving a classification 47 No classification is perfect 47 Rule-based Classification 47 Post-classification editing 53 Making interactive edits 54 Making class edits 55 Attaching a representation file to a classification 61 Modifying and saving the representation file 61 Importing a representation file 62 Exporting the classification 63 Converting the classification to a raster file 63 Creating a pseudocolor segment 65 Exporting the pseudocolor segment to geocoded RGB 66 Creating a GeoTIFF file 67

Performing object-based image analysis - PCI Geomatics

Page vi PCI Geomatics

Performing object-based image analysis - PCI Geomatics

PCI Geomatics Page 7 I In nt tr ro od du uc ct ti io on n A Ab bo ou ut t O Ob bj je ec ct t A An na al ly ys st t In Geomatica Focus, you can use Object Analyst, an object-based image-analysis (OBIA) feature, to segment an image into objects for classification and analysis. It differs from the traditional pixel-based approach, which focuses on a single pixel as the source of analysis. Object Analyst is designed primarily for use with very-high-resolution (VHR) imagery; however, you can use the feature with any imagery that meets the necessary criteria.

That is, you can use imagery of lower resolution, of various resolutions, and that is in a supported format.

By working with objects, which are extracted through a segmentation process, analysis is both simplified and more sophisticated. That is, by using objects, human-visual interpretation of images is augmented by using the software to do much of the preliminary work to create and determine which shapes, of given sizes, textures, and so forth, are of interest. W Wo or rk kf fl lo ow w o of f o ob bj je ec ct t- -b ba as se ed d i im ma ag ge e a an na al ly ys si is s Before you attempt to work with the imagery in Object Analyst, you must first preprocess your data. For example, if you are using more the one satellite image, such as is used in this tutorial, you can merge them into a single PCIDSK file.

By doing so, you can more easily apply operations like resampling or reprojection to make the data easier to work with. You can also add extra layers, such as vegetation indices, a digital elevation model (DEM), or a layer representing an area of interest (AOI).

After preprocessing, you can then segment the data with Object Analyst. Segmentation is the first step of the supervised OBIA process. It involves selecting a file and the layers it contains to run segmentation. When a file contains several layers, consider creating a one or more subsets. Doing so can achieve better results (better objects). Other than the selected layers, segmentation is controlled by three basic parameters: scale, shape, and compactness. Typically, to achieve segmentation that meets the objectives of your supervised classification, some experimentation is necessary.

The objects (polygons) layer created by segmentation is accompanied by an attribute table containing a unique identification number (ID) for each object.

Performing object-based image analysis - PCI Geomatics

Introduction Performing object-based image analysis Page 8 PCI Geomatics After segmentation, you next run attribute calculation. This involves selecting the source channel or channels from which to compute a series of attributes (statistical and geometrical) for each object in the segmentation layer. You can select which attributes to compute. The attributes are used later during supervised classification. Next, you edit training sites. This consists of selecting a series objects representative of each land-cover class of interest. To make editing training sites easier, consider the following: • Select approximatively the same number of training sites for each class.

• Select a few representative training objects for each class. That is, selecting too many training objects for a class does not improve the classification accuracy; rather, it may degrade it. Conversely, the number of verification objects can be much greater and will improve the reliability of the accuracy assessment.

Supervised classification uses the Support Vector Machine (SVM) classifier. The input is a selection of calculated attributes and one training-site field. The output is stored in a new field, and the output classification is displayed automatically, including its relevant legend, in Focus. You next evaluate the output classification by creating an accuracy-assessment report and visually inspecting the output classification using the original image or ancillary data. If the classification is satisfactory, you can export it. If the classification is unsatisfactory, you can do any of the following: • Post-classification Editing (A)1 This operation helps you to improve the aesthetic of your classification.

You can select from Automatic dissolve, Interactive edits, or Class edits. Automatic dissolve merges contiguous objects of the same class. To adjust the shape of selected objects, select Interactive edits. By selecting Class edits, you can manually reassign the class of selected objects to a new class. Typically, you do post-classification editing at the end of the classification process; alternatively, make a copy of your segmentation file, and then do post-classification editing on it.

• Rule-based Classification (B) This operation refines an existing supervised classification by reassigning the class of some objects based on conditions or ranges. You can define and apply a classification rule that you have created on classified or unclassified segments. The prerequisite is the attribute calculation of each object. After classification, you can either remove a class for some or all segments, or change the membership of certain segments in a class to improve the overall accuracy of the classification.

Another scenario is when no classification is performed and you want to assign certain segments to a class based on criteria you specify.

You can create an attribute field in a vector layer to store the class information, and then create a rule by using the available extracted attributes. 1 Each alphabetical designator relates to the workflow diagram of object-based image analysis on page 7.

Performing object-based image analysis - PCI Geomatics

Performing object-based image analysis Introduction PCI Geomatics Page 9 • Run another supervised Classification (C) You can run a second supervised classification by selecting a different set of attributes, a different training-sites field (see next item), or both if your project contains more than one. • Modifying an existing training-site field or create a new one (D) When a classification is particularly unsatisfactory and cannot be improved by rule-based classification, consider modifying the training-sites field by: a) modifying the training site of a particular class by deleting an existing training site or selecting new ones; b) creating a new existing land-cover class, or c) removing an existing land-cover class.

Alternatively, you can create a new training field for easier analysis and, ultimately, a satisfactory classification. • Extract new attributes (E) At times it may be necessary to extract new attributes before rerunning the supervised classification. • Run a new segmentation (F) If after several attempts the classification is still unsatisfactory, you can run a new segmentation. If you do so, you must also rerun Attribute Calculation, Training Sites Editing, and supervised Classification. Note You can neither export nor transfer training and verification sites from one segmentation to another.

Performing object-based image analysis - PCI Geomatics

Introduction Performing object-based image analysis Page 10 PCI Geomatics W Wo or rk kf fl lo ow w d di ia ag gr ra am m o of f o ob bj je ec ct t- -b ba as se ed d i im ma ag ge e a an na al ly ys si is s Figure 1 shows the general workflow of object-based image analysis (OBIA). Figure 1. Workflow of OBIA

Performing object-based image analysis Introduction PCI Geomatics Page 11 P Pr ro oj je ec ct t a ar rc ch hi it te ec ct tu ur re e It is good practice to keep all relevant files of your project in the same folder and to link all files in a Geomatica project file (.gpr).

By doing so, you ensure that the project is exportable and can be reopened quickly, especially if a project contains many classifications, each with a legend. A typical project contains an image file and a segmentation file. The segmentation is run on the image layers (all or subset). The project can also contain ancillary data: raster or vector. While you cannot use ancillary-raster data for segmentation—you can use only the layers in the image being segmented—you can use the ancillary-raster data later in attribute calculation.

Figure 2. Folder organization of a typical project The project will also typically contain an object field, either for training or accuracy assessment, from which a supervised classification is produced. The classification can often be improved by extracting additional attributes or by editing the object field. A project can contain several segmentation files derived from the same image. Each segmentation is characterized by a different set of layers and parameters (scale, shape, compactness). A segmentation file contains a set of attributes (statistical or geometrical) you specify, and which you can expand anytime during classification .

The segmentation can also contain several fields corresponding to a different set of training and accuracy objects, where the number of land-cover (or land-use) classes can vary and, therefore, will produce a different classification of the same area.

However, because the calculated attributes depend on the configuration of a particular segmentation, you cannot transfer training and accuracy objects from one segmentation to another.

Introduction Performing object-based image analysis Page 12 PCI Geomatics Figure 3. Folder organization of a more complex project Typically, segmentation and attribute calculation are run on the same image. However, you can run segmentation and extract some attributes on one image and use another image to extract a second set of attributes. To do so, you must ensure that the second image contains the entire segmentation; otherwise, all objects outside the boundary of the second image will be set to zero.

PCI Geomatics Page 13 R Re eg gi io on n o of f s st tu ud dy y, , o ob bj je ec ct ti iv ve e, , d da at ta a R Re eg gi io on n o of f s st tu ud dy y The region of study (ROS) is centered in Ottawa (45°25′14.22′′N; 75° 41′47.30′′W), the capital of Canada. The northern part of the ROS is rugged and hilly and is part of the Canadian Shield. This region is mostly forested (deciduous and mixed deciduous) with numerous lakes. Delimited by the Ottawa River, the southern part of the ROS is the Great Lakes-St. Lawrence Lowlands. Where the drainage is good, this region is mostly prime agricultural land while areas of poor drainage are mostly covered by a mix of wetlands and forested areas composed of tree species that support saturated soils.

Figure 4. Region of study (acquired September 5, 2016)2 In Figure 5, the ROS is shown in a Landsat-8 image. 2 Credit: Google Earth

Region of study, objective, data Performing object-based image analysis Page 14 PCI Geomatics Figure 5. Landsat-8 (p16r28 and p16r29) image of ROS (acquired August 26, 2016 (R: Band 6 | G: Band 5 | B: Band 4) O Ob bj je ec ct ti iv ve e The objective of this tutorial is to perform a supervised object-based classification to identify the following land-cover classes: 1. Agricultural areas 2. Urban areas 3. Forested land 4. Water 5. Wetlands However, these high-level land-cover classes do contain some heterogeneity and discriminating them is not a trivial task. The tutorial will demonstrate various strategies to achieve suitable results: 1.

Use remote-sensing imagery acquired during various seasons to account for the dynamic nature of agricultural land and ease discrimination between coniferous and broad-leaf tree species. 2. Segmentation; that is, information generalization by regrouping pixels into meaningful objects.

3. Use a robust, nonlinear classifier: Support Vector Machine (SVM).

Performing object-based image analysis Region of study, objective, data PCI Geomatics Page 15 4. Separate some land-cover classes into subclasses to later merge. The urban land cover is divided into two classes: urban dense and urban with vegetation. 5. Post-classification enhancements. Note At this point, clouds and their shadows will be omitted initially with supervised classification. Later, during post- classification editing, you will learn how to work with clouds. In the following table, four Landsat-8 OLI images of the Ottawa region have been downloaded from the USGS Glovis website.

No. Scene Path Row Acquisition date 1 LC80160282016127LGN00 16 28 May 6, 2016 2 LC80160292016127LGN00 16 29 May 6, 2016 3 LC80160282016239LGN00 16 28 August 26, 2016 4 LC80160292016239LGN00 16 29 August 26, 2016 In Geomatica OrthoEngine, two mosaics, one for each acquisition date, were produced. Because this was done only to reassemble an image previously split in rows for archiving, no color balancing was applied. Band Name (wavelength), spatial resolution Used for segmentation Used for attribute calculatio n B1 Coastal/Aerosol (0.435-0.451 μm)-30m B2 Blue (0.452-0.512 μm)-30m √ B3 Green (0.533-0.590 μm)-30 √ B4 Red (0.636-0.673 μm)-30m √ √ B5 Near Infrared (0.851-0.879 μm)-30m √ √ B6 Short-wave Infrared-1 (1.556-1.651 μm)-30m √ √ B7 Short-wave Infrared-2 (2.107-2.294 μm)-30m √ B8 Panchromatic (0.503-0.676 μm)-15m B9 Cirrus (1.363-1.384 μm) 30m B10 Thermal Infrared -1(10.60-11.19 μm) -100m B11 Thermal Infrared-2 (11.50-12.51 μm) -100m Each mosaic was reprojected to UTM-18T (WGS84) and subsetted with the following bounds: • Upper left: 372 285E; 5 078 025.000N • Lower right: 479 565E; 4 979 475.000N The final step was to merge the two subsetted mosaics into a single PCIDSK file for a total of 14 spectral channels.

This file, L8_Ottawa_20160506_20160826.pix, is provided with this tutorial.

PCI Geomatics Page 17 S Se eg gm me en nt ta at ti io on n a an nd d a at tt tr ri ib bu ut te e c ca al lc cu ul la at ti io on n S Se eg gm me en nt ta at ti io on n i is s k ke ey y The success of an object-based supervised classification starts with a good segmentation. Unfortunately, there are no objective rules to follow or absolute criteria to tell whether a segmentation is good. As a guideline, a trade-off is often necessary between the mean size of objects (generalization) and their homogeneity. That is, most objects should, in general, correspond to only one land- cover class and their shapes should align with the boundaries (edges) observed in the imagery.

Segmentation also depends on the selected layers (in this case, the spectral bands) and it is not mandatory to use all available layers. Shape, scale, and compactness parameters are also assigned to the objects. Choosing a good combination increases the success of the supervised classification and requires some experimentation. The following series of images shows the results of various combinations of scale (SC), shape (SP) and compactness (CP) values from the segmentation of the B6, B5, and B4 bands (followed by the total number of objects) for May 6 and August 26, 2016.

SC:25, SP:0.10, CP:0.5 (3 356 129) SC:50, SP:0.10, CP:0.5 (589 186) SC:100, SP:0.10, CP:0.5 (136 928)

Segmentation and attribute calculation Performing object-based image analysis Page 18 PCI Geomatics SC:25, SP:0.25, CP:0.5 (2 608 795) SC:50, SP:0.25, CP:0.5 (493 238) SC:100, SP:0.25, CP:0.5 (139 528) SC:25, SP:0.50, CP:0.5 (1 003 221) SC:50, SP:0.50, CP:0.5 (338 648) SC:100, SP:0.50, CP:0.5 (97 889) SC:25, SP:0.75, CP:0.5 (662 681) SC:50, SP:0.75, CP:0.5 (182 387) SC:100, SP:0.75, CP:0.5 (57 007) SC:25, SP:0.80, CP:0.5 (531 987) SC:50, SP:0.80, CP:0.5 (150 372) SC:100, SP:0.80, CP:0.5 (44 572)

Performing object-based image analysis Segmentation and attribute calculation PCI Geomatics Page 19 SC:25, SP:0.90, CP:0.5 (212 739) SC:50, SP:0.80, CP:0.5 (83 488) SC:100, SP:0.80, CP:0.5 (24 599) R Ru un nn ni in ng g S Se eg gm me en nt ta at ti io on n In this step, you will run Segmentation on a Landsat image.

Figure 6. Operation list with Segmentation selected To run Segmentation 1. In Focus, open the Landsat image provided with this tutorial (L8_Ottawa_20160506_20160826.pix). 2. On the Analysis menu, Object Analyst. The Object Analyst window appears. 3. In the Operation list, select Segmentation. 4. Under Source Channels, click Select. The Layer Selection window appears

Segmentation and attribute calculation Performing object-based image analysis Page 20 PCI Geomatics 5. In the File list, select L8_Ottawa_20160506_20160826.pix, and then select the spectral bands, as shown. That is, because the objective of this tutorial is to classify the high-level land cover classes based on imagery acquired at two different seasons (spring and late summer), the spectral bands that emphasize the vegetation changes for these two seasons will be used. 6. After you select the bands, click OK. 7. In the Object Analyst window, under Parameters, enter values as follows: ▪ Scale: 50 ▪ Shape: 0.8 ▪ Compactness: 0.5 8.

Under Output, click Browse, and then enter the path and file name to which to write the segmentation result.

That is, enter the path and file name as follows: ▪ ~\OA_Tutorial_Ottawa\L8_Ottawa_SEG_B6B5B4_50_0.8_0.5.pix 9. In the Layer box, enter seg1. 10. Click Add and Run . The operation is added under Process Canvas and the segmentation process begins. Figure 7. Object Analyst window with Segmentation set up to run After the process is complete, the segmentation layer will appear in Focus displayed over the Landat-8 image, as shown in Figure 8.

Performing object-based image analysis Segmentation and attribute calculation PCI Geomatics Page 21 Figure 8. Segmentation layer in Focus The segmentation layer contains the following four fields: • ShapeID - unique value for every object • Area (sq m) • Perimeter (m) • PixelValue V Vi ie ew wi in ng g t th he e s se eg gm me en nt ta at ti io on n l la ay ye er r i in n A At tt tr ri ib bu ut te e M Ma an na ag ge er r You can view information about the segmentation layer in Attribute Manager.

To view the segmentation layer in Attribute Manager 1. In the Focus window, on the Files tab, expand the L8_Ottawa_SEG_B6B5B4_50_0.8_0.5.pix file. 2. Right-click the vector layer ([VEC]), and then click Attribute Manager.

Segmentation and attribute calculation Performing object-based image analysis Page 22 PCI Geomatics C Cr re ea at ti in ng g a a G Ge eo om ma at ti ic ca a p pr ro oj je ec ct t f fi il le e The Geomatica project file you create will contain the Landsat-8 image, the segmentation layer, and, later, the classification result. To create and save a Geomatica project file 1. On the File menu, click Save Project. 2. Enter the following as the path and file name: ~\OA_Tutorial_Ottawa\Ottawa_OA.gpr A At tt tr ri ib bu ut te e C Ca al lc cu ul la at ti io on n In this step, you will run Attribute Calculation.

Figure 9. Operation list with Attribute Calculation selected The term attribute, in object-based image analysis (OBIA), corresponds to an attribute representing some information about the image objects. In Object Analyst, the same concept is used. Different characteristics of image objects are referred to as attributes of an object.

You can calculate the following types of attribute: • Statistical • Geometrical

Performing object-based image analysis Segmentation and attribute calculation PCI Geomatics Page 23 Statistical attributes are calculated based on the image pixels inside an object. Attributes are computed for each of the selected image bands and added to the attribute table of the segmented layer as new fields (attributes). The minimum, maximum, the mean, and the standard deviation are available. Geometrical attributes that represent geometric characteristics of an object polygon segment) make OBIA advantageous over pixel-based analysis.

In Object Analyst, the geometric attributes are computed by analyzing the polygon boundary created during segmentation, so raster information is not required. Object Analyst computes many shape descriptors used commonly, such as compactness, elongation, circularity, and rectangularity.

In this tutorial, the mean of all spectral bands will be calculated for each object. This will be sufficient for a general land-cover/land-use classification. To run Attribute Calculation 1. In the Object Analyst window, in the Operation list, select Attribute Calculation. 2. Under Source Channels, click Select. The Layer Selection window appears. 3. Select L8_Ottawa_20160506_20160826.pix as the input file, and then select the bands to use. If necessary, in the Band Alias column, you can modify the alias by clicking the corresponding box, and then entering a new value. The new band alias will appear as the corresponding fields in the attribute table.

The following figures show the acquisition date added to the band aliases. 4. After you modify any band aliases, click OK.

5. Under Segmented Vector Layer, click Select, and then enter L8_Ottawa_SEG_B6B5B4_50_0.8_0.5.pix as the input segmentation file.

Segmentation and attribute calculation Performing object-based image analysis Page 24 PCI Geomatics 6. Click OK. 7. Under Attributes to Calculate, expand Statistical, select the Mean check box, and make sure the other check boxes are clear. 8. Click Add and Run . The operation is added under Process Canvas and the attribute- calculation process begins. Figure 10. Object Analyst window with Attribute Calculation set up to run After the process is complete, you can view the selected statistics for image L8_Ottawa_SEG_B6B5B4_50_0.8_0.5.pix in the Attribute Manager window.

Performing object-based image analysis Segmentation and attribute calculation PCI Geomatics Page 25 Figure 11. Attribute Manager showing selected statistics for image L8_Ottawa_SEG_B6B5B4_50_0.8_0.5.pix

PCI Geomatics Page 27 C Co ol ll le ec ct ti in ng g a an nd d e ed di it ti in ng g t tr ra ai in ni in ng g s si it te es s T Tr ra ai in ni in ng g s si it te es s The next operation is to collect and edit training sites. With a supervised classification, this is perhaps the most crucial operation and can be labor intensive.

You can use the following series of figures as a guide to help you to collect training and verification classes for each land-cover class. Class No. May 6, 2016 August 26, 2016 Class /description 1 Wetlands - marsh 1 Wetland - peatlands

Collecting and editing training sites Performing object-based image analysis Page 28 PCI Geomatics Class No. May 6, 2016 August 26, 2016 Class /description 2 Forest - coniferous 3 Forest - deciduous 4 Water

Performing object-based image analysis Collecting and editing training sites PCI Geomatics Page 29 Class No. May 6, 2016 August 26, 2016 Class /description 5 Urban - dense 6 Urban –with vegetation 7 Agriculture – bare (in May)

Collecting and editing training sites Performing object-based image analysis Page 30 PCI Geomatics Class No.

May 6, 2016 August 26, 2016 Class /description 8 Agriculture – vegetation (in May) S Se el le ec ct ti in ng g a a t tr ra ai in ni in ng g v ve ec ct to or r l la ay ye er r a an nd d t tr ra ai in ni in ng g f fi ie el ld d With Training Sites Editing, you select a vector layer and field, and then select objects on which to base the training. You can also, if necessary, import ground- truth points to assist with the training. Figure 12. Operation list with Training Sites Editing selected To select a training vector layer 1. In the Object Analyst window, in the Operation list, select Training Sites Editing.

2. Under Training Vector Layer, click Select, and then select a segmentation file. In this case, select L8_Ottawa_SEG_B6B5B4_50_0.8_0.5.pix, and then click OK. 3. Click Edit. The Training Sites Editing window appears. 4. In the Training field list, make sure Training (the default name) is selected. 5. Click Close. The new field is added to L8_Ottawa_SEG_B6B5B4_50_0.8_0.5.pix.

Performing object-based image analysis Collecting and editing training sites PCI Geomatics Page 31 Tip If necessary, in the Training Sites Editing window you can create a new training field.

Beside the Training Field list, click Create. In the Training Field window, enter a name in the Field name box, and then click Create. To create a new class and select training or accuracy objects 1. In the Training Sites Editing window, click Add Class. 2. In the Class Name column of the table, enter a class name, and then in the Color column, select a color.

The color will be assigned to the classification (you can change it later, if necessary). 3. Beside Sample type, click Training. 4. Switch to the Focus window, and then in the view pane, pan, zoom, or both, as necessary to find an area representative of wetlands. 5. Click Individual Select , click an object in the image, and then in the Training Sites Editing window, click Assign. You can select multiple objects to assign by holding down the Shift key and clicking each object you want. You can also drag a selection square or rectangle over the objects you want.

6. In the Training Sites Editing window, beside Sample type, click Accuracy assessment, and repeat step 5 to select objects for accuracy assessment.

Note: You cannot use the same object simultaneously for training and accuracy assessment. If an object is already assigned to a class, and you select it again, it will be updated with the new state. The same rule applies to a class selected previously.

Collecting and editing training sites Performing object-based image analysis Page 32 PCI Geomatics 7. Repeat steps 1 to 6 for each class. Tip Save your project regularly. In Attribute Manager, the Training field of L8_Ottawa_SEG_B6B5B4_50_0.8_0.5.pix is updated for each object selected for training (_T) of accuracy assessment (_A). Figure 13. Training fields updated in Attribute Manager

Performing object-based image analysis Collecting and editing training sites PCI Geomatics Page 33 Figure 14. Training site with classes defined Color R-G-B Class 255-102-0 Wetlands 0-153-0 Forest - coniferous 0-250-0 Forest - deciduous 0-0-255 Water 0-0-0 Urban - dense 74-74-74 Urban - vegetation 255-204-255 Agriculture - bare 204-51-204 Agriculture -vegetation Figure 15.

Position of training and accuracy-assessment objects used in this tutorial

Collecting and editing training sites Performing object-based image analysis Page 34 PCI Geomatics I Im mp po or rt ti in ng g g gr ro ou un nd d- -t tr ru ut th h p po oi in nt ts s If necessary, you can import ground-truth points. The file containing the points must be a vector-point file with a single attribute table describing the class of each vector point. The format of the field containing the class labels can be text or integer. A ground-truth point file is provided with this tutorial (~\data\GT_Points_CL_ID_ClassName.pix). The file contains 169 records and three fields and, among them, you can use the following to import the ground-truth points: • -CL_ID: A numeric code (integer) unique to each land-cover class.

• -Class_Name: A text field describing each land-cover class. Any disparity between two class labels will be treated as a different class. To import ground-truth points 1. In the Object Analyst window, under Training Vector Layer, click Select.

The Layer Selection window appears. 2. In the File box, type the path and name of the file you want—the segmentation file to update with the new ground-truth points—or, to select a file, click Browse, and then select the file you want. After you select the file, in the Select column, click the layer you want. 3. In the Object Analyst window, under Ground-Truth Points, click Import. The Import Ground-Truth Points window appears.

Performing object-based image analysis Collecting and editing training sites PCI Geomatics Page 35 4. Do the following: ▪ In the File box, type the path and name of the file you want or, to select a file, click Browse, and then select the file you want.

▪ In the Layer list, select the layer you want, and then in the Field list, select the field you want. ▪ Beside Sample type, click Training, as applicable. ▪ In the Conflict-resolution rule list, select a rule. When you select Majority you can, if necessary, type or select a minimum threshold in the box to the right.

5. Click Import. A message appears, displaying a summary of the imported points. V Vi ie ew wi in ng g t th he e u up pd da at te ed d c cl la as ss se es s i in n A At tt tr ri ib bu ut te e M Ma an na ag ge er r After importing the ground-truth points, switch to Attribute Manager. Notice that each class name in the Class_Name column has been appended with *_T to indicate a training sample. A Class_Name_Count column has also been added, which provides a count of the number of ground-truth points per object. Figure 16. Updated Class_Name fields in Attribute Manager In the following figure, 169 of 150372 objects have been updated.

Collecting and editing training sites Performing object-based image analysis Page 36 PCI Geomatics Figure 17. Imported ground-truth points with CL_ID field (integer) Note You can modify class names at any time in the Training Sites Editing window or in the Class Editing window.

PCI Geomatics Page 37 C Cl la as ss si if fi ic ca at ti io on n S Se el le ec ct ti in ng g t th he e s se eg gm me en nt ta at ti io on n f fi il le e a an nd d a at tt tr ri ib bu ut te e f fi ie el ld ds s The next operation is to run Supervised Classification to classify the data using some calculated attributes, statistical or geometrical, in combination with a field containing training (Class_Name_T) and accuracy-assessment (Class_Name_A) objects.

Note You can use the following file included with the tutorial: L8_Ottawa_SEG_543_50_0.8_0.3_T_A.pix. Figure 18. Operation list with Supervised Classification selected To set up the classification 1. In the Operation list, select Supervised Classification. 2. Under Vector Layer and Fields, click Select, and then in the Vector Layer and Field Selector window, do the following: ▪ Select L8_Ottawa_SEG_B6B5B4_50_0.8_0.5.pix as the segmentation file.

▪ Select the attribute fields (statistical, geometrical, or both) to use for the classification. You can select all or a subset of the calculated attributes. Select all statistical attributes (mean) calculated previously. ▪ Click OK. 3. In the Training field list, select the field of the segmented layer with the training and accuracy objects (Training). 4. In the Output class field box, type SVM_T1 as the name of the field to which to write the classification result. Attribute Manager will be updated with the field in the segmentation file. 5. If you want to normalize the data during the classification, select the Normalize data check box; otherwise, proceed to run the classification.

Classification Performing object-based image analysis Page 38 PCI Geomatics To run classification 1. Click Add and Run . The operation is added under Process Canvas and the classification process begins. 2. After the classification process is complete, save your project. In Attribute Manager, you can view the following new fields added for L8_Ottawa_SEG_B6B5B4_50_0.8_0.5.pix: • *_ClassLabel: Unique integer label assigned automatically to each class. • SVM_T1: Result of the classification. • *_Voting_Prob: SVM voting probability. Use this field to assess the strength of the classification for each object.

Figure 19. Attribute Manager showing the three new fields added

Performing object-based image analysis Classification PCI Geomatics Page 39 V Vi ie ew wi in ng g a a c cl la as ss si if fi ic ca at ti io on n After the classification process is complete, in Focus, a legend appears on the Maps tab. The color of each class corresponds to those specified during selection of the training and verification objects. Note By default, the opacity is set at 25 percent for quick interpretation of the results. To modify the styles of your classification 1. On the Maps tab, under L8_Ottawa_SEG_543_50_0.8_0.3_T_A.pix:2. New Layer: SVM_t1, double-click Agriculture_bare.

The Style Selector window appears.

Each class has two parts, the object interior color (Polygon – Fill) and its contour (Line – Solid). To see all the available options for modifying the class style, switch between Advanced and Simple modes. Note: You may need to first click More. 2. Click Advanced, and then in table in the Definition area, in the box beside Opacity, type 100. This sets the opacity of the class to 100 percent. 3. To preview the change, click Apply, and then to accept the change, click OK.

Changes to styles are saved automatically. 4. Repeat steps 1 to 3 to set the opacity of each class to 100.

Classification Performing object-based image analysis Page 40 PCI Geomatics You can also remove the outline of a classified object by, in Advanced mode, selecting 2 in the Part list, and then clicking Remove . Figure 20. Supervised classification with modified styles

Performing object-based image analysis Classification PCI Geomatics Page 41 The following series of images show the progression of the image as processed with Object Analyst.

Landsat-8 May 6, 2016. R: Band 6 G: Band 5 B: Band 4 Landsat-8 August 26, 2016. R: Band 6 G: Band 5 B: Band 4 Supervised classification result (detail) With object contour

Classification Performing object-based image analysis Page 42 PCI Geomatics Supervised classification result (detail) Without object contour Note You can further refine the appearance of the classes in the Class Editing window.

PCI Geomatics Page 43 A Ac cc cu ur ra ac cy y A As ss se es ss sm me en nt t E Ev va al lu ua at ti in ng g c cl la as ss si if fi ic ca at ti io on n a ac cc cu ur ra ac cy y You can evaluate the accuracy of a classification by switching between the classification and the source imagery. You can also, if necessary, create an accuracy report.

Figure 21. Operation list with Accuracy Assessment selected To create an accuracy report 1. In the Operation list, select Accuracy Assessment. 2. Under Classified Results, do the following: ▪ In the Classified vector layer list, select the segmentation file that contains a classification result from a supervised classification; that is, select L8_Ottawa_SEG_B6B5B4_50_0.8_0.5.pix.

▪ In the Classification field list, select the field that contains the classification result; that is, select SVM_TI. ▪ In the Reference field list, select the field that contains the training and accuracy objects used to generate the selected classification field; that is, select Training.

Accuracy Assessment Performing object-based image analysis Page 44 PCI Geomatics 3. Click Generate Report. The Accuracy Assessment Report window appears. The Accuracy Assessment Report window has three tabs: • Sample Listing: Shows all assessed samples, with georeferenced position, image coordinates, classified value/name, and reference value/name.

• Error (Confusion) Matrix: Shows a matrix of all classes between reference data and classified data. • Accuracy Statistics: Shows various accuracy statistics, such as overall accuracy, kappa coefficient, and confidence intervals.

After you create an accuracy-assessment report, you can export it to a Microsoft Excel spreadsheet (.xls) or text file (.txt).

Performing object-based image analysis Accuracy Assessment PCI Geomatics Page 45 To export an accuracy-assessment report 1. In the Accuracy Assessment Report window, on the Sample Listing tab, Error (Confusion) Matrix tab, or Accuracy Statistics tab, as applicable, click Export Report. The File Selector window appears. 2. In the File Selector window, select a folder, enter a file name for the report, and then click Save. Figure 22.

Sample accuracy-assessment report

PCI Geomatics Page 47 E Ed di it ti in ng g a an nd d i im mp pr ro ov vi in ng g a a c cl la as ss si if fi ic ca at ti io on n N No o c cl la as ss si if fi ic ca at ti io on n i is s p pe er rf fe ec ct t Even if a high degree of accuracy has been achieved, it is unlikely that the classification is perfectly suited to the project. Typically, before exporting a classification refinement of some land-cover classes or some manual editing might be necessary. While Object Analyst provides several options for refining a classification, this section will focus on the following methods: • Rule-based classification • Merging and reshaping objects • Manually editing classes R Ru ul le e- -b ba as se ed d C Cl la as ss si if fi ic ca at ti io on n In addition to supervised and unsupervised classification algorithms, you can create custom rules to assign new class membership to a selection of objects.

Figure 23. Operation list with Rule-based Classification selected Based on your knowledge of the area to classify, you can build a series of conditions (or rules) based on several attributes to reassign objects from one class to another. Essentially, building a condition is to create an equation based on a single attribute or two different attributes linked by a logical operator (AND/OR). Building a condition is highly user-dependent; that is, you do so by exploring your data and doing onscreen analysis of the image and objects.

Another feature to help you with a rule-based classification is Attribute Visualization. With this feature, you can visually select objects from an existing class based on the thresholding of one attribute.

Editing and improving a classification Performing object-based image analysis Page 48 PCI Geomatics For example, a close inspection of the classification reveals that the wetland class is too general; it would be better to split the class into two subclasses: • Wooded wetland, mostly coniferous (dense to sparse tree cover) • Open wetland (no trees) To do so, you will use the interactive Attribute Visualization feature.

To reassign a class by using Attribute Visualization 1. In the Operation list, select Rule-based Classification. 2. Under Vector Layer, select the segmentation file with the classification field to modify; that is, select L8_Ottawa_SEG_B6B5B4_50_0.8_0.5.pix. 3. Under Class Edit, click Assign. 4. Under Parameters, do the following: ▪ In the Class field list, select the field with the classification to modify; that is, select SVM_T1.

▪ In the Class filter list, select the land-cover class to modify; that is, select Wetlands. ▪ In the New class list, select the destination class. This can be an existing class or a new class; however, you will create a new class by typing Wetland_open. 5. To interactively reassign the class, select the Specify condition check box, and then click Attribute Visualization. The Attribute Visualization window appears.

Performing object-based image analysis Editing and improving a classification PCI Geomatics Page 49 Fortunately, the near infrared band is sufficient to allow a good discrimination between the wooded and open wetlands.

To guide your range selection, in Focus, open the wetland vector map from Natural Resources Canada included with the tutorial. To open the wetland vector map 1. In Focus, on the File menu, click Open, and then select Wetlands_Canvec_50K.pix. 2. In the Attribute Visualization window, drag the Minimum value and Maximum value sliders to compare the values.

In Focus, notice that the selected objects appear in a different color. Optionally, you can deselect the other classes to help you to find the best range because only the wetland class will be modified. The following figures show the variations of the minimum and maximum values. In Figure 24, the leftmost image shows only the wetland class displayed in orange. The rightmost image shows the May 6, 2016 Landsat image (R: Near Infrared, G: Red, B; Green). The open wetlands appear as light purple in the leftmost image. These are the candidates for the new open-wetland class. Notice that the wetland reference data is now displayed with a thicker white outline around the polygon so they are more easily differentiated from the objects classified as wetlands.

Editing and improving a classification Performing object-based image analysis Page 50 PCI Geomatics Figure 24. Sample new-wetland class In Figure 25, the selected objects are displayed as yellow. These are the candidates of the new open-wetland class; however, too few objects are selected (narrow selection) and candidate objects for the new open-wetland class are still in the wetland class (orange). Figure 25. Sample new-wetland class (too few objects selected)

Performing object-based image analysis Editing and improving a classification PCI Geomatics Page 51 In Figure 26, the majority of objects are selected (yellow).

Despite the broad selection, some obvious candidate objects to the open-wetland class still belong to the wetland class (orange). Figure 26. Sample new-wetland class (too many objects selected) In Figure 27, a suitable range was found by lowering the minimum value and setting the maximum value of the NIR band to 15942. Objects belonging to the new open-wetland class are selected in yellow and the objects remaining in the original wetland class are in orange.

Figure 27. Suitable range After you find a suitable range, in the Attribute Visualization window, click OK. You can now apply your changes to the classification.

Editing and improving a classification Performing object-based image analysis Page 52 PCI Geomatics To apply your changes • In the Object Analyst window, click Add and Run . Figure 28. Object Analyst window with Attribute Visualization In Attribute Manager, the SVM_T1 field is updated with the new Wetland_open class. Figure 29. Attribute Manager showing updated SVM_T1 field The new class has also been added to the legend.

Performing object-based image analysis Editing and improving a classification PCI Geomatics Page 53 Figure 30. Class added to legend P Po os st t- -c cl la as ss si if fi ic ca at ti io on n e ed di it ti in ng g With Post-classification Editing, you can improve the aesthetic of your classification. Figure 31. Operation list with Post-classification Editing selected You can choose from the following options: • Automatic dissolve: Merges two adjacent polygons based on class membership • Interactive edits: Merge or split polygons you select • Class edit: Add or remove classes Caution Before attempting post-classification editing, back up your project.

Any changes you make to object shapes and the total number of objects render the extracted attributes (statistical and geometrical) invalid.

Editing and improving a classification Performing object-based image analysis Page 54 PCI Geomatics M Ma ak ki in ng g i in nt te er ra ac ct ti iv ve e e ed di it ts s The selected layer must have one or more polygons with class information To merge adjacent polygons 1. In the Operation list, select Post-classification Editing. 2. Under Type, click Interactive edits. 3. Under Vector Layer, select the segmentation file with the classification field you want to modify; that is, select L8_Ottawa_SEG_B6B5B4_50_0.8_0.5.pix. 4. Under Editing Tools, click Individual Select , and then in Focus, click the first polygon you want to merge.

5. Click Merge Polygon , and then in Focus, click one or more polygons to merge. To undo a merge, on the File menu, click Undo. You can also press Ctrl+Z. The following image shows before and after merging. 6. After you merge the polygons you want, on the Maps tab, right-click the map layer, and then click Save.

Performing object-based image analysis Editing and improving a classification PCI Geomatics Page 55 M Ma ak ki in ng g c cl la as ss s e ed di it ts s You can manually add, modify, and remove classes, as necessary. You can also assign objects to a class, and change the style (color, borders, opacity) of how classes are displayed in the view pane.

You can also continually assign a new class to selected objects. To manually edit a class 1. In the Operation list, select Post-classification Editing. 2. Under Type, click Class edit.

3. Under Vector Layer, select the segmentation file with the classification field you want to modify; that is, select L8_Ottawa_SEG_B6B5B4_50_0.8_0.5.pix. 4. In the Class field list, select the field containing the classification you want to edit; that is, select SVM_T1. 5. Click Edit. The Class Editing window appears (beside Style for All Class, click ).

Editing and improving a classification Performing object-based image analysis Page 56 PCI Geomatics Assigning objects to an existing class In the following procedure, you will assign some misclassified objects to the Deciduous class, as shown in the red circles in Figure 32.

Figure 32. Misclassified objects (circled in red) In Figure 33, an object misclassified as Agriculture_bare is selected. Figure 33. Object belonging to Agriculture_bare selected, reassigning to Deciduous

Performing object-based image analysis Editing and improving a classification PCI Geomatics Page 57 In the Class Name column of the table, click Deciduous, and then click Assign. The object is now assigned to the Deciduous class, as shown in Figure 34. Figure 34. Object assigned to Deciduous class Continuously assigning objects to a new class In the following procedure, you will create a new class, Clouds, and continuously assign objects to it. To continuously assign objects to a new class 1. In the Class Editing window, click Add. A new class is added to the Class Name column of the table.

2. Select the new class, rename it Clouds, and then in the Color column, select the color as white.

3. In the Focus window, on the Maps tab, select the Landsat images and display channels 9, 10, and 11 in the Blue, Green, and Red images. 4. In the view pane, select an area in which there are clouds. 5. In the Class Editing window, adjust the transparency of your classification so you can see the clouds underneath. For example, set the classification opacity to 40 percent and the border color to red. 6. In the Class Name column of the table, select the destination class, Clouds, and then click Continuously Assign.

Editing and improving a classification Performing object-based image analysis Page 58 PCI Geomatics 7.

On the toolbar, click , and then in the view pane of the Focus window, select one or more objects. After you select the object or objects, the original class will be assigned automatically to Clouds. 8. Repeat the previous step to select additional clouds and their shadows. 9. On completion, click Continuously Assign again to switch off the feature. The final results of the class reassignment are shown in Error! Reference source not found. and Error! Reference source not found..

Performing object-based image analysis Editing and improving a classification PCI Geomatics Page 59 Figure 35. Landsat image with clouds Figure 36. Modified classification with new Cloud class

PCI Geomatics Page 61 A At tt ta ac ch hi in ng g a a r re ep pr re es se en nt ta at ti io on n f fi il le e t to o a a c cl la as ss si if fi ic ca at ti io on n M Mo od di if fy yi in ng g a an nd d s sa av vi in ng g t th he e r re ep pr re es se en nt ta at ti io on n f fi il le e The styles you apply to a classification are saved in your project file.

If the segmentation file that contains the classification field is opened standalone in Focus or in another project the styles will be unavailable. To retain your styles for future use, create a representation file (*.rst). You can do so at any stage of your project.

To modify the representation file 1. In Focus, on the Maps tab, right-click the vector layer with the classification result you want, and then click Representation Editor. The Representation Editor window appears. 2. To modify the style of a class, in the Style column of the table, double- click the class. The Style Selector window appears. 3. Select a style, and then click Apply. 4. Repeat steps 2 and 3 for each class you want to modify, and then click OK.

Attaching a representation file to a classification Performing object-based image analysis Page 62 PCI Geomatics To save the representation file 1.

On the toolbar of the Representation Editor window, click Save ( ). The Save As window appears. 2. In the File box, you can type or select the name you want; that is, select SVM_T1. 3. In the Description box, type a brief description to help you—and most importantly, others—identify the relevance of the file. I Im mp po or rt ti in ng g a a r re ep pr re es se en nt ta at ti io on n f fi il le e When you want to use the representation you created in Modifying and saving the representation file in a project, you can import the file. That is, when you open a classification without an associated Geomatica project file (*.gpr), you can import the representation file you created previously.

To import a representation file 1. In Focus, open the classification. 2. On the Maps tab, right click the classification, and then click Representation Editor. The Representation Editor window appears. 3. In the Attribute list, select the field with the supervised class labels; that is, select SVM_T1. 4. On the toolbar, click Link ( ). The RST Link window appears. 5. In the File list, select the file you created previously; that is, select Classif_SVM_T1.rst, and then click OK. 6. In the Representation Editor window, click Apply, and then click OK. The styles are now associated with the classification you selected.

PCI Geomatics Page 63 E Ex xp po or rt ti in ng g t th he e c cl la as ss si if fi ic ca at ti io on n C Co on nv ve er rt ti in ng g t th he e c cl la as ss si if fi ic ca at ti io on n t to o a a r ra as st te er r f fi il le e While Geomatica features various methods by which you can export a classification to another format, this tutorial describes using the POLY2RAS algorithm to convert the classification to a raster file using a class-label field. You then create a pseudocolor table (PCT) and assign the various colors to each class. To convert the classification to a raster layer 1. In Focus, on the Tools menu, click Algorithm Librarian.

The Algorithm Librarian window appears.

2. Open the POLY2RAS algorithm. The POLY2RAS Module Control Panel window appears. 3. Under Input Ports, click Browse, and then select L8_Ottawa_SEG_B6B5B4_50_0.8_0.5.pix as the input polygon layer and bounding area. 4. Under Output Ports, type a path and SVM1_classif.pix as the file name for the output file.

Exporting the classification Performing object-based image analysis Page 64 PCI Geomatics 5. Click the Input Params 1 tab, and then do the following: ▪ In the Output type list, select Raster. ▪ In the Field name box, type Label. 6. Click Run. The classification you specified is converted to a single-channel, 8-bit file.

Performing object-based image analysis Exporting the classification PCI Geomatics Page 65 C Cr re ea at ti in ng g a a p ps se eu ud do oc co ol lo or r s se eg gm me en nt t The output of POLY2RAS is a gray-valued, 8U single channel. The numeric values correspond to the values stored in the specified POLY2RAS field name. Figure 37. Numeric values in Geomatica Focus To create a pseudocolor segment 1. In Focus, on the Files tab, right-click the image channel you want, point to View, and then click As Pseudocolor. 2. Click the Maps tab, and then expand the pseudocolor file ( ). 3. Double-click the square beside class 1 , and then in the Change PCT Entry Color window, click a new (RGB) color for the class, and then click OK.

4. Repeat step 3 for classes 2 through 8, selecting the color you want for each class. 5. Right-click the pseudocolor file, and then click Save As. The Save As window appears. 6. Save the pseudocolor segment to the PCIDSK file that contains the classification.

Exporting the classification Performing object-based image analysis Page 66 PCI Geomatics E Ex xp po or rt ti in ng g t th he e p ps se eu ud do oc co ol lo or r s se eg gm me en nt t t to o g ge eo oc co od de ed d R RG GB B A pseudocolor segment is now attached to the classification. When you open the classification in Focus, it will display with the colors you selected.

You can now export the file to a geocoded RGB file by running the PCE algorithm. To encode the single channel pseudocolor classification to an RGB file 1. In Focus, open the Algorithm Librarian, and then open the PCE algorithm.

The PCE Module Control Panel window appears. 2. For Input: Layer to Encode, select the 8U channel containing the classification. 3. For InputPCT: Pseuodocolor Layer Table, select the PCT you created previously. 4. For the output file, enter the path and SVM1_Classif_RGB.pix as the file name. 5. Click Run.

Performing object-based image analysis Exporting the classification PCI Geomatics Page 67 C Cr re ea at ti in ng g a a G Ge eo oT TI IF FF F f fi il le e After you create the new RGB file, you can export it to a GEOTIFF file by using the Translate command in Focus.

To create a geoTIFF file 1. In Focus, click the File menu, point to Utility, and then click Translate. The Translate (Export) File window appears. 2. For Source file, select the RGB file you created previously. 3. For Destination file, select a path and SVM1_Classif_RGB.tif as the file name.

4. In the Output format list, select TIF: TIFF 6.0. 5. Under Source Layers, select all three 8U raster channels, and then add them to the Destination Layers list by clicking > Add >. 6. Click Translate.

PCI Geomatics Page 69

pcigeomatics.com info@pcigeomatics.com