# Object Analyst Classification - Geomatica Banff

PCI Geomatics -

Geomatica’s Object Analyst provides an intuitive workflow wizard for performing image segmentation, classification and feature extraction. This all-in-one interface is designed to reduce complexity and give users the opportunity to develop highly accurate, object-based, thematic classification maps. The following steps are outlined in this tutorial:

Object Analyst Workflow

Segmentation

Attribute Calculation

Training Site Collection

Manually Collect Training Sites

Import Ground-Truth Points

Supervised Classification

Unsupervised Classification

Accuracy Assessment

Rule-Based Classification

Attribute Visualisation

Post Classification Editing

Automatic Dissolve

Interactive Edits

Class Edit

Symbolizing Classification Results

## Tutorial Data

Your tutorial data package should include the following file:

inputs.pix – .pix is PCI’s proprietary file format and can contain many raster channels, vector layers and more. This file contains 3 imagery channels (RGB), 1 surface model and 1 greenness index channel. The surface model and greenness index channels can be generated using algorithms and tools available in Geomatica

Note: You will need to unzip the package before you can continue with the tutorial

Click on the following link and fill in the quick form to access a free trial of Geomatica: www.GetGeomatica.com

In this section we are going to simply load and review the different layers that will be used as inputs to segmentation and object-based classification.

1. Open Focus from the Geomatica Toolbar and then click Open
2. Navigate to the file that you downloaded and open inputs.pix. It will automatically load as true colour composite (R:1, G:2, B:3)

1. Click on the Files tab in the layer and files manager on the left side of Focus
2. Expand the Rasters branch to view the individual rasters contained in the pix file

1. Right click on layer 4 (Surface Model) and select View > As Grayscale. A normalized Surface Model will render in grayscale.

1. Right click on layer 5 (Greeness Index) and select View > As Pseudocolor. A psuedocolor image is displayed which represents the areas that are more green versus areas that are less green. The areas in red represent high amount of green color, whereas the areas in green represent low amount of green color.

1. The final layer in the inputs.pix file is the Ground Truth Point vector file. Right click the segment and click View. The points will then be loaded. This segment will be used in the Training Sites Editing - Import Ground-Truth Points

1. On the Maps tab, move the pix RGB layer to the top so that it is rendering in the viewer.

## Object Analyst Workflow

You use Object Analyst, an object-based image-analysis (OBIA) module, 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 for use primarily with very-high-resolution (VHR) imagery; however, you can use Object Analyst with any imagery that meets the necessary criteria. That is, you can use imagery of lower resolution, of various resolutions, and that is in an input format supported by Focus.

The object analyst workflow as outlined above includes the following steps:

• Segmentation
• Attribute Calculation
• Training Sites Editing
• Supervised Classification
• Unsupervised Classification
• Rule-Based Classification
• Post Classification Editing
• Accuracy Assessment

## Segmentation

This section provides the steps necessary to perform the segmentation of your imagery and subsequent layers (i.e. feature heights layer, greenness index layer).

1. In the Object Analyst wizard, click on the Operation dropdown list and select Segmentation
2. In the Source image layers section, click Select…
3. In the File drop down list, select the only file in the list (pix)
4. Select the first 4 channels (not the 5th channel). The layers selected in this panel will be used for segmenting the image

1. Click OK
2. Although this tutorial will not use an area of interest, there is the option in the segmentation step to set an AOI. The segmentation will then be constrained to a specific AOI, which can help to speed up the segmentation process.
• To set an AOI, open the PCIDSK file (and layer) containing the polygons that you want to use.
• In the Object Analyst window, select the Use area of interest check box, and then in the AOI layer list, select the PCIDSK file and layer containing the polygons you want

1. In the Parameters section, set the Scale to 35
2. In the Output section, click Browse…
3. In the File Selector window, set the file name to seg and click Save
4. In the Layer dropdown list, click to type in the name of the new layer on which the segmentation results will be saved: tutorial_seg

1. Click on the Add and Run button
2. After processing, your segmentation layer should be loaded into the Focus viewer

## Attribute Calculation

1. In the Object Analyst wizard, click on the Operation dropdown list and select Attribute Calculation
2. In the Source Channels section, click on Select…
3. Keep channels 1 - 4 checked, but this time also check channel 5
4. Change the Band Alias names to the following: B01 > Red, B02 > Green, B03 > Blue, B04 > Heights, B05 > Greenness

1. Click OK
2. In the Attributes to Calculate section, expand the Statistical section and check off Mean
3. Expand the Geometrical section and check the following: Compactness, Elongation, Circularity, Rectangularity.
4. In Geomatica Banff there are new attributes in the Geometrical, Vegetation Indices and Texture categories. More information on these is available from the Geomatica help.

2. In the Maps tab, right click on the pix:2. tutorial_seg layer and in the context menu, select Attributes Manager…

In the Attributes Manager that opens, you will see a number of new columns with the headers that you just created in step 4 (e.g. Mean_red, Mean_green, Mean_blue, Rectangularity, etc.

1. Close the Attribute Manager

## Training Site Collection

This section will provide the steps required to collect training sites necessary to perform a supervised classification. Furthermore, you will also collect validation sites, which will be used for performing quantitative accuracy assessment after you run the classification process.

1. In the Object Analyst wizard, change the Operation to Training Sites Editing
2. Make sure that the Training Vector Layer is pix: 2 [VEC]:tutorial_seg the file that you created in the Segmentation section of this tutorial

There are two possible methods of entering Training Sites:

• Edit – Manually select the training sites by adding segmentation polygons to classes.
• Ground-Truth Points – Use a point file that contains ground-truth information to specify the training class for segmentation polygons.

### Manually Collect Training Sites

1. Click on the Edit… button to open up the Training Sites Editing window
2. Ensure that Training Field is set to Training
3. Click on the Add Class button
4. A new row will be added that reads Class 1 under the Class Name column
5. Change the name to Buildings
6. Click on the color dropdown list to select a color to represent that class (e.g. dark grey)
7. Repeat steps 4-7, four (4) more times and name each class as follows
• Pavement (set color to light grey)
• Soil (set color to orange)
• Forest (set color to dark green)
• Field (set to yellow)
• Grass (set color to bright green)
8. Select the Buildings class and then click on the Individual Select tool
9. In the Focus viewer, hold the CTRL key down and select the segmentation polygons that overlap buildings (make sure to select at least 30 buildings of different roof colors and styles)

1. Once you have selected a number of different building polygons, click the Assign button on the Training Sites Editing window, to add them to the Training Count column for your Buildings class
2. Use the Individual Select tool again to select at least 20 more buildings
3. Repeat steps 9-14 for the remaining four classes, making sure to collect at least 25 shapes for the Training count. Try to be as accurate and diverse in your collection as possible
4. You can repeat the steps above to manually collect training sites for Accuracy Count or you could Import Ground Truth Points as explained in the section below.

### Import Ground-Truth Points

1. From the main Object Analyst window - Training Sites Editing operation, click on the Import button
2. In the Import Ground-Truth Points window select the pix file, Ground Truth Points layer and Class field. These points will be used for Accuracy assessment

1. Each polygon in the segmentation layer that contains a ground-truth point will then be added to a specific Accuracy Assessment class, based on the value in the field Class. You can open the attribute manager for the Ground-Truth Point segment to view the field values.

1. Change the Conflict-resolution rule to First
2. Click Import
3. The points are imported and a report pop-up appears.

1. You can then open the Training Sites Editing window, switch the Training Field to class and view the new Accuracy Assessment polygons that resulted from the point import.
2. You will want a minimum of 15 training sites for each Accuracy Assessment class. Collect additional accuracy assessment training sites for each class following steps 9 and 10 from Manually Collect Training Sites.

** Make sure that the Sample Type radio button is switched to Accuracy Assessment before collecting the sites.

## Supervised Classification

Once the training sites are collected, you can run a supervised classification. Supervised classification is a process to find a model, or function, by analyzing the attributes of a data set of which the class memberships are known. This function is then used to predict the class memberships for target population.

1. In the Object Analyst window, change the Operation to Supervised Classification
2. Click on the Select… button in the Vector Layer and Fields section
3. In the Vector Layer and Field Selector window, make sure that the Layer field is populated with the tutorial_seg layer and that all of the Fields have a checkmark next to them, except for Area, Perimeter, and Class_Count

1. Click OK
2. In the Training Field dropdown list, select Training
3. In the Output Class Field, change the name to Supervised
4. Leave the SVM kernel as Radial-basis function and then click Add and Run
5. Ensure that Normalize Data is checked off. You may also check off Save training model if you wish to preserve the classification routine for use in a Python script.

1. Once the process has finished running, go to the Maps tab and uncheck the Training layer to view your results.
2. You can always adjust the classification representation using the Post-Classification > Class Edit operation.

## Unsupervised Classification

An alternative to supervised classification is unsupervised classification. With an unsupervised classification, training samples are not required. This classification is performed on the selected attributes to find data clusters. Object Analyst provides unsupervised classification based on the k-means clustering algorithm.

1. In the Object Analyst window, change the Operation to Unsupervised Classification
2. Click Select and choose the segmentation file and tutorial_seg layer.
3. Check all of the boxes except Area, Perimeter, PixelValue, Class_Count and Supervised_classlabel

1. Change the Output Class Field to Unsupervised
2. Change the Clusters value to 7

2. The unsupervised classification is loaded into the Maps tab.
3. You can reload the supervised classification results to the Maps tab as well to compare the two classifications. See Symbolizing Classification Results to visualize the information.
4. In the case of unsupervised classification, you will need to determine which unsupervised classes best correspond to the ground features. If there are multiple ground features included in a single unsupervised class, you can run Rule-Based Classification to create additional classes and reclassify segments.

## Accuracy Assessment & Refining Results

This section will provide the steps necessary to perform an accuracy assessment. This step can be run before or after refining the classification with Rule-Based Classification. Running it before rule-based classification will let us know which classes need to be refined.

1. In the Object Analyst window, click on the Operation dropdown list and select Accuracy Assessment
2. Change the Classification field to Supervised
3. Change the Reference field to Class
4. Click Generate Report

An Accuracy Assessment Report opens with two useful accuracy measures:

• Error (Confusion) Matrix – Provides details about which training and accuracy sites were classified into different classes

• Accuracy Statistics – Provides a range of useful statistics to see how well features were classified

You will notice from our run, that every class had an accuracy result greater than 85%, except for Field. With this information, we can use rule-based classification to adjust this class.

## Rule-Based Classification

In addition to supervised and unsupervised classification algorithms, with Object Analyst you can also create a custom rule to assign class membership to segments. By creating a custom rule, as an analyst you can select the criteria that determines membership of a sample in a class based on your understanding of the domain, data, or both.

You can define a rule to either assign a class to segments that meet the requirements of the rule or remove the segments from the class.

### Attribute Visualization

In the Attribute Visualization window, you can select the vector objects (polygon segments) in the vector layer based on a given attribute (field) and its value range (filter).

In the supervised classification, areas that are shadow were classified as forest.  In the images below you will notice that the building shadows are part of the forest class (darker green).

We will use the rule-base classification to assign the shadow segments to a new Shadow class.

1. In the Object Analyst window, change the Operation to Rule-Based Classification
2. Ensure that tutorial_seg is selected as the layer and Assign is selected as the Class Edit.
3. Change Class Field to Supervised, Class filter to Forest and New class to Shadow (you can type this in)

1. Check off Specify condition and click Attribute Visualization
2. In the Attribute Visualization window change Class Field to Supervised and Class filter to
3. Change the Range Field to Mean_Greenness. In the greenness channel, the shadowed areas will be much darker than the actual forest.
4. As you adjust the slider bars, you will notice different segments being selected.
5. Move the slider bars until enough of the shadow segments are selected. If you set the Maximum value too high, you will reclassify too much forest as shadow.

1. Click OK
2. In the object analyst window the condition box will be filled: Mean_Greeness >= 126.6577835083 and Mean_Greeness <= 129.5192260406
4. Open the Representation Editor for the Supervised classification in the Maps tab. You will notice that there is now a new class.
5. Specify a new colour for this class such as black.
6. Click OK on the representation editor. The shadow class will now be included in your classification.

1. You can follow these same steps to reclassify segments from other classes.

## Post Classification Editing

Once the classification is complete, you may want to modify aspects of your classification. Modifications you can make include the following:

• Merge, split or dissolve polygons
• Add new classes, remove existing ones, or reassign objects of a class

### Automatic Dissolve

Automatic dissolve merges two adjacent polygons based on class membership; that is, segments belonging to the same class and that are adjacent to each other are dissolved to create a bigger object. The internal boundaries of such segments are removed. The output will exclude all the attribute fields, except the field that contains the class-membership information. It is this field that is used to dissolve the segments.

1. In the Object Analyst window, in the list under Operation, select Post-classification Editing.
2. Under Type, select Automatic Dissolve
3. Under Vector Layer, click Select, and then choose tutorial_seg
4. In the Class field list, select the field you want – Supervised
5. Set the output file and layer name

2. You can load the dissolved layer into the Focus window and update the representation to view the results.

### Interactive Edits

An alternative to reforming shapes with Automatic dissolve is to use Interactive edits. To do so, you must select a layer that contains one or more polygons with class information.

1. In the Object Analyst window, in the list under Operation, select Post-classification Editing.
2. Under Type, select Interactive edits.
3. Under Vector Layer, select tutorial_seg
4. To merge polygons:
• Select the Merge Polyon tool
• Select a polygon. When you move the cursor over surrounding polygons you will notice that it has changed.
• Select any surrounding polygons, to merge them with the original polygon

1. To Split Polygons:
• Select the polygon you want to split with the Select tool
• Once selected, select the Split Polygon tool
• You can then draw a line through the polygon to split it

### Class Edit

You can add, modify, and remove classes, as necessary. You can also assign objects to a class, and change the style of how classes are displayed in the view pane.

1. In the Object Analyst window, in the list under Operation, select Post-classification Editing.
2. Under Type, select Class edit.
3. Under Vector Layer, click Select, and then choose tutorial_seg. You can choose to select the Segmentation or Dissolve layer.
4. In the Class field list, select the field you want. In this case we will choose the Supervised class
5. Click Edit. The Class Editing window appears.
6. You then add, remove or update classes in this window.
7. This window can also be used to change the representation colour and style for the classes.

• Click Add in the Class Editing window
• Rename the class
• Select the new class from the list
• Click the Selection tool and select a segment in the Focus window
• Click Assign, to assign that segment to the new class

Reassign Segments

• Select the Class that you wish to reassign the segments to in the Class Editing window.
• Select the segment that you wish to reassign. You can select multiple segments at one time.
• Click Assign
• If you click Continuously Assign, the objects that you select will be continuously assigned to the selected class.

Delete a Class

• Select a class from the Class Editing list and click Remove
• If your class currently has segments assigned to it, you will receive an error. You need to reassign items to another class. Once the class is empty, you can remove it.

The classification and editing is now complete. You can rerun Accuracy Assessment to check the improvement in accuracy.

## Symbolizing Classification Results

If you open a segmentation vector layer in a new Focus window you will need to adjust the representation for that layer in order to view the classification:

1. Right-click the tutorial_seg layer in the Files tab and choose View
2. In the Maps tab, right-click the new tutorial_seg layer > Representation Editor
3. In the representation editor, change the Attribute option to the supervised or unsupervised classification field – Supervised/Unsupervised
4. Click More >>
5. Make sure the method is Unique Values is selected
6. Make sure the Generate new styles option is selected and that you choose the style that you want to use.
7. Click Update Styles
8. You can then change the colour of each class in the top section of the panel.