About Classification

Key Classification Concepts

Please take a look at these videos where you learn basic steps in eCognition:

Getting Started 1 of 4: Create a project

Getting Started 2 of 4: First dynamic classification

Getting Started 3 of 4: Improve your objects

Getting Started 4 of 4: Export your results

Assigning Classes

When editing processes, you can use the following algorithms to classify image objects:

Class Descriptions and Hierarchies

You will already have a little familiarity with class descriptions and hierarchies from the basic tutorial, where you manually assigned classes to the image objects derived from segmentation..

There are two views in the Class Hierarchy window, which can be selected by clicking the tabs at the bottom of the window:


The Class Hierarchy window - Groups and Inheritance tab

Double-clicking a class in either view will launch the Class Description dialog box. The Class Description box allows you to change the name of the class and the color assigned to it, as well as an option to insert a comment. Additional features are:


The Class Description Dialog Box

Creating and Editing a Class

There are two ways of creating and defining classes; directly in the Class Hierarchy window, or from processes in the Process Tree window.

Creating a Class in the Class Hierarchy Window

To create a new class, right-click in the Class Hierarchy window and select Insert Class. The Class Description dialog box will appear.


The Class Description Window

Enter a name for your class in the Name field and select a color of your choice. Press OK and your new class will be listed in the Class Hierarchy window.

Creating a Class as Part of a Process

Many algorithms allow the creation of a new class. When the Class Filter parameter is listed under Parameters, clicking on the value will display the Edit Classification Filter dialog box. You can then right-click on this window, select Insert Class, then create a new class using the same method outlined in the preceding section.

The Assign Class Algorithm

The Assign Class algorithm is a simple classification algorithm, which allows you to assign a class based on a condition (for example a brightness range):

In the Algorithm Parameters pane, opposite Use Class, select a class you have previously created, or enter a new name to create a new one (this will launch the Class Description dialog box)

Editing the Class Description

You can edit the class description to handle the features describing a certain class and the logic by which these features are combined.

  1. Open a class by double-clicking it in the Class Hierarchy window.
  2. To edit the class description, open either the All or the Contained tab.
  3. Insert or edit the expression to describe the requirements an image object must meet to be member of this class.
Inserting an Expression

A new or an empty class description contains the 'and (min)' operator by default.


Context menu of the Class Description dialog box


Insert Expression dialog box

 

Although logical terms (operators) and similarities can be inserted into a class as they are, the nearest neighbor and the membership functions require further definition.

Moving an Expression

To move an expression, drag it to the desired location.


Moving expressions using drag-and-drop operations.
Editing an Expression

To edit an expression, double-click the expression or right-click it and choose Edit Expression from the context menu. Depending on the type of expression, one of the following dialog boxes opens:

Operator for Expression

The following expression operators are available in eCognition if you select Edit Expression or Insert expression > Logical terms:

Example: Consider four membership values of 1 each and one of 0. The 'and'-operator yields the minimum value, i.e., 0, whereas the 'or'-operator yields the maximum value, i.e., 1. The arithmetic mean yields the average value, in this case a membership value of 0.8.

See also Fuzzy Classification using Operators and Adding Weightings to Membership Functions.

Select Operator for Expression window
Evaluating Undefined Image Objects

Image objects retain the status 'undefined' when they do not meet the criteria of a feature. If you want to use these image objects anyway, for example for further processing, you must put them in a defined state. The function Evaluate Undefined assigns the value 0 for a specified feature.

  1. In the Class Description dialog box, right-click an operator
  2. From the context menu, select Evaluate Undefined. The expression below this operator is now marked.
Deleting an Expression

To delete an expression, either:

Using Samples for Nearest Neighbor Classification

The Nearest Neighbor classifier is recommended when you need to make use of a complex combination of object features, or your image analysis approach has to follow a set of defined sample image objects. The principle is simple – first, the software needs samples that are typical representatives for each class. Based on these samples, the algorithm searches for the closest sample image object in the feature space of each image object. If an image object's closest sample object belongs to a certain class, the image object will be assigned to it.

For advanced users, the Feature Space Optimization function offers a method to mathematically calculate the best combination of features in the feature space. To classify image objects using the Nearest Neighbor classifier, follow the recommended workflow:

  1. Load or create classes
  2. Define the feature space
  3. Define sample image objects
  4. Classify, review the results and optimize your classification.

Defining Sample Image Objects For the Nearest Neighbor classification, you need sample image objects. These are image objects that you consider a significant representative of a certain class and feature. By doing this, you train the Nearest Neighbor classification algorithm to differentiate between classes. The more samples you select, the more consistent the classification. You can define a sample image object manually by clicking an image object in the map view.

You can also load a Test and Training Area (TTA) mask, which contains previously manually selected sample image objects, or load a shapefile, which contains information about image objects.

Adding Comments to an Expression

Comments can be added to expressions using the same principle described in Adding Comments to Classes.

The Edit Classification Filter


The Edit Classification Filter dialog box

The Edit Classification Filter is available from the Edit Process dialog for appropriate algorithms (e.g. Algorithm classification) and can be launched from the Class Filter parameter.

The buttons at the top of the dialog allow you to:

The Use Array drop-down box lets you filter classes based on arrays.

Classification Algorithms

The Assign Class Algorithm

The Assign Class algorithm is the most simple classification algorithm. It uses a condition to determine whether an image object belongs to a class or not.

  1. In the Edit Process dialog box, select Assign Class from the Algorithm list
  2. The Image Object Level domain is selected by default. In the Parameter pane, select the Condition you wish to use and define the operator and reference value
  3. In the Class Filter, select or create a class to which the algorithm applies.

The Classification Algorithm

The Classification algorithm uses class descriptions to classify image objects. It evaluates the class description and determines whether an image object can be a member of a class.

Classes without a class description are assumed to have a membership value of one. You can use this algorithm if you want to apply fuzzy logic to membership functions, or if you have combined conditions in a class description.

Based on the calculated membership value, information about the three best-fitting classes is stored in the image object classification window; therefore, you can see into what other classes this image object would fit and possibly fine-tune your settings. To apply this function:

  1. In the Edit Process dialog box, select classification from the Algorithm list and define the domain
  2. From the algorithm parameters, select active classes that can be assigned to the image objects
  3. Select Erase Old Classification to remove existing classifications that do not match the class description
  4. Select Use Class Description if you want to use the class description for classification. Class descriptions are evaluated for all classes. An image object is assigned to the class with the highest membership value.

The Hierarchical Classification Algorithm

The Hierarchical Classification algorithm is used to apply complex class hierarchies to image object levels. It is backwards compatible with eCognition 4 and older class hierarchies and can open them without major changes.

The algorithm can be applied to an entire set of hierarchically arranged classes. It applies a predefined logic to activate and deactivate classes based on the following rules:

  1. Classes are not applied to the classification of image objects whenever they contain applicable child classes within the inheritance hierarchy.
    Parent classes pass on their class descriptions to their child classes. (Unlike the Classification algorithm, classes without a class description are assumed to have a membership value of 0. )
    These child classes then add additional feature descriptions and – if they are not parent classes themselves – are meaningfully applied to the classification of image objects. The above logic is following the concept that child classes are used to further divide a more general class. Therefore, when defining subclasses for one class, always keep in mind that not all image objects defined by the parent class are automatically defined by the subclasses. If there are objects that would be assigned to the parent class but none of the descriptions of the subclasses fit those image objects, they will be assigned to neither the parent nor the child classes.
  2. Classes are only applied to a classification of image objects, if all contained classifiers are applicable.
    The second rule applies mainly to classes containing class-related features. The reason for this is that you might generate a class that describes objects of a certain spectral value in addition to certain contextual information given by a class-related feature. The spectral value taken by itself without considering the context would cover far too many image objects, so that only a combination of the two would lead to satisfying results. As a consequence, when classifying without class-related features, not only the expression referring to another class but the whole class is not used in this classification process.
    Contained and inherited expressions in the class description produce membership values for each object and according to the highest membership value, each object is then classified.

If the membership value of an image object is lower than the pre-defined minimum membership value, the image object remains unclassified. If two or more class descriptions share the highest membership value, the assignment of an object to one of these classes is random.

The three best classes are stored as the image object classification result. Class-related features are considered only if explicitly enabled by the corresponding parameter.

Using Hierarchical Classification with a Process


Settings for the Hierarchical Classification algorithm
  1. In the Edit Process dialog box, select Hierarchical Classification from the Algorithm drop-down list
  2. Define the Domain if necessary.
  3. For the Algorithm Parameters, select the active classes that can be assigned to the image objects
  4. Select Use Class-Related Features if necessary.

Advanced Classification Algorithms

Advanced classification algorithms are designed to perform specific classification tasks. All advanced classification settings allow you to define the same classification settings as the classification algorithm; in addition, algorithm-specific settings must be set. The following algorithms are available:

Thresholds

Using Thresholds with Class Descriptions

A threshold condition determines whether an image object matches a condition or not. Typically, you use thresholds in class descriptions if classes can be clearly separated by a feature.

It is possible to assign image objects to a class based on only one condition; however, the advantage of using class descriptions lies in combining several conditions. The concept of threshold conditions is also available for process-based classification; in this case, the threshold condition is part of the domain and can be added to most algorithms. This limits the execution of the respective algorithm to only those objects that fulfill this condition. To use a threshold:

About the Class Description

The class description contains class definitions such as name and color, along with several other settings. In addition it can hold expressions that describe the requirements an image object must meet to be a member of this class when class description-based classification is used. There are two types of expressions:

You can use logical operators to combine the expressions and these expressions can be nested to produce complex logical expressions.

Using Membership Functions for Classification

Membership functions allow you to define the relationship between feature values and the degree of membership to a class using fuzzy logic.

Double-clicking on a class in the Class Hierarchy window launches the Class Description dialog box. To open the Membership Function dialog, right-click on an expression – the default expression in an empty box is 'and (min)' – to insert a new one, select Insert New Expression. You can edit an existing one by right-clicking and selecting Edit Expression.


The Membership Function dialog box

Membership Function Type

For assigning membership, the following predefined functions are available:

Button Function Form
Larger than
Smaller than
Larger than (Boolean, crisp)
Smaller than (Boolean, crisp)
Larger than (linear)
Smaller than (linear)
Linear range (triangle)
Linear range (triangle inverted)
Singleton (exactly one value)
Approximate Gaussian
About range
Full range

Fuzzy Classification using Operators

After the manual or automatic definition of membership functions, fuzzy logic can be applied to combine these fuzzified features with operators. Generally, fuzzy rules set certain conditions which result in a membership value to a class. If the condition only depends on one feature, no logic operators would be necessary to model it. However, there are usually multidimensional dependencies in the feature space and you may have to model a logic combination of features to represent this condition. This combination is performed with fuzzy logic. Fuzzy logic allows the modelling several concepts of 'and' and 'or'.
The most common and simplest combination is the realization of 'and' by the minimum operator and 'or' by the maximum operator. When the maximum operator 'or (max)' is used, the membership of the output equals the maximum fulfilment of the single statements. The maximum operator corresponds to the minimum operator 'and (min)' which equals the minimum fulfilment of the single statements. This means that out of a number of conditions combined by the maximum operator, the highest membership value is returned. If the minimum operator is used, the condition that produces the lowest value determines the return value. The other operators have the main difference that the values of all contained conditions contribute to the output, whereas for minimum and maximum only one statement determines the output.

When creating a new class, its conditions are combined with the minimum operator 'and (min)' by default. The default operator can be changed and additional operators can be inserted to build complex class descriptions, if necessary. For given input values the membership degree of the condition and therefore of the output will decrease with the following sequence:

See also Operator for Expression.

To change the default operator, right-click the operator and select 'Edit Expression.'

You can now choose from the available operators. To insert additional operators, open the 'Insert Expression' menu and select an operator under 'Logical Terms.' To insert an inverted operator, activate the 'Invert Expression' box in the same dialog; this negates the operator (returns 1 – fuzzy value): 'not and (min).' To combine classes with the newly inserted operators, click and drag the respective classes onto the operator.

A hierarchy of logical operator expressions can be combined to form well-structured class descriptions. Thereby, class descriptions can be designed very flexibly on the one hand, and very specifically on the other. An operator can combine either expressions only, or expressions and additional operators - again linking expressions.

An example of the flexibility of the operators is given in the image below. Both constellations represent the same conditions to be met in order to classify an object.

Hierarchy of loagical operators

Generating Membership Functions Automatically

In some cases, especially when classes can be clearly distinguished, it is convenient to automatically generate membership functions. This can be done within the Sample Editor window (for more details on this function, see Working with the Sample Editor).

To generate a membership function, right-click the respective feature in the Sample Editor window and select Membership Functions > Compute.


Sample Editor with generated membership functions and context menu

Membership functions can also be inserted and defined manually in the Sample Editor window. To do this, right-click a feature and select Membership Functions > Edit/Insert, which opens the Membership Function dialog box. This also allows you to edit an automatically generated function.


Automatically generated membership function

To delete a generated membership function, select Membership Functions > Delete. You can switch the display of generated membership functions on or off by right-clicking in the Sample Editor window and activating or deactivating Display Membership Functions.

Editing Membership Function Parameters

You can edit parameters of a membership function computed from sample objects.


The Membership Function Parameters dialog box
  1. In the Sample Editor, select Membership Functions > Parameters from the context menu. The Membership Function Parameters dialog box opens
  2. Edit the absolute Height of the membership function
  3. Modify the Indent of membership function
  4. Choose the Height of the linear part of the membership function
  5. Edit the Extrapolation width of the membership function.

Editing the Minimum Membership Value

The minimum membership value defines the value an image object must reach to be considered a member of the class.

If the membership value of an image object is lower than a predefined minimum, the image object remains unclassified. If two or more class descriptions share the highest membership value, the assignment of an object to one of these classes is random.

To change the default value of 0.1, open the Edit Minimum Membership Value dialog box by selecting Classification > Advanced Settings > Edit Minimum Membership Value from the main menu.


The Edit Minimum Membership Value dialog box

Adding Weightings to Membership Functions

The following expressions support weighting:

 


Adding a weight to an expression

Weighting can be added to any expression by right-clicking on it and selecting Edit Weight. The weighting can be a positive number, or a scene or object variable. Information on weighting is also displayed in the Class Evaluation tab in the Image Object Information window.

Weights are integrated into the class evaluation value using the following formulas (where w = weight and m = membership value):

 

Using Similarities for Classification

Similarities work like the inheritance of class descriptions. Basically, adding a similarity to a class description is equivalent to inheriting from this class. However, since similarities are part of the class description, they can be used with much more flexibility than an inherited feature. This is particularly obvious when they are combined by logical terms.

A very useful method is the application of inverted similarities as a sort of negative inheritance: consider a class 'bright' if it is defined by high layer mean values. You can define a class 'dark' by inserting a similarity feature to bright and inverting it, thus yielding the meaning dark is not bright.

It is important to notice that this formulation of 'dark is not bright' refers to similarities and not to classification. An object with a membership value of 0.25 to the class 'bright' would be correctly classified as' bright'. If in the next cycle a new class dark is added containing an inverted similarity to bright the same object would be classified as 'dark', since the inverted similarity produces a membership value of 0.75. If you want to specify that 'dark' is everything which is not classified as 'bright' you should use the feature Classified As.

Similarities are inserted into the class description like any other expression.

Evaluation Classes

The combination of fuzzy logic and class descriptions is a powerful classification tool. However, it has some major drawbacks:

There are two ways to avoid these problems – stagger several process containing the required conditions using the Parent Process Object concept (PPO) or use evaluation classes. Evaluation classes are as crucial for efficient development of auto-adaptive rule sets as variables and temporary classes.

Creating Evaluation Classes

To clarify, evaluation classes are not a specific feature and are created in exactly the same way as 'normal' classes. The idea is that evaluation classes will not appear in the classification result – they are better considered as customized features than real classes.

Like temporary classes, we suggest you prefix their names with '_Eval' and label them all with the same color, to distinguish them from other classes.

To optimize the thresholds for evaluation classes, click on the Class Evaluation tab in the Image Object Information window. Clicking on an object returns all of its defined values, allowing you to adjust them as necessary.


Optimize thresholds for evaluation classes in the Image Object Information window

Using Evaluation Classes

In this example, the rule set developer has specified a threshold of 0.55. Rather than use this value in every rule set item, new processes simply refer to this evaluation class when entering a value for a threshold condition; if developers wish to change this value, they need only change the evaluation class.


Example of an evaluation class

TIP: When using this feature with the geometrical mean logical operator, ensure that no classifications return a value of zero, as the multiplication of values will also result in zero. If you want to return values between 0 and 1, use the arithmetic mean operator.

Supervised Classification

Nearest Neighbor Classification

Classification with membership functions is based on user-defined functions of object features, whereas Nearest Neighbor classification uses a set of samples of different classes to assign membership values. The procedure consists of two major steps:

  1. Training the system by giving it certain image objects as samples
  2. Classifying image objects in the image object domain based on their nearest sample neighbors.

The nearest neighbor classifies image objects in a given feature space and with given samples for the classes of concern. First the software needs samples, typical representatives for each class. After a representative set of sample objects has been declared the algorithm searches for the closest sample object in the defined feature space for each image object. The user can select the features to be considered for the feature space. If an image object's closest sample object belongs to Class A, the object will be assigned to Class A.

All class assignments in eCognition are determined by assignment values in the range 0 (no assignment) to 1 (full assignment). The closer an image object is located in the feature space to a sample of class A, the higher the membership degree to this class. The membership value has a value of 1 if the image object is identical to a sample. If the image object differs from the sample, the feature space distance has a fuzzy dependency on the feature space distance to the nearest sample of a class (see also Setting the Function Slope and Details on Calculation).


Membership function created by Nearest Neighbor classifier

For an image object to be classified, only the nearest sample is used to evaluate its membership value. The effective membership function at each point in the feature space is a combination of fuzzy function over all the samples of that class. When the membership function is described as one-dimensional, this means it is related to one feature.


Membership function showing Class Assignment in one dimension

In higher dimensions, depending on the number of features considered, it is harder to depict the membership functions. However, if you consider two features and two classes only, it might look like the following graph:


Membership function showing Class Assignment in two dimensions. Samples are represented by small circles. Membership values to red and blue classes correspond to shading in the respective color, whereby in areas in which object will be classified red, the blue membership value is ignored, and vice-versa. Note that in areas where all membership values are below a defined threshold (0.1 by default), image objects get no classification; those areas are colored white in the graph

Detailed Description of the Nearest Neighbor Calculation

eCognition computes the distance d as follows:

Distance between sample object s and image object o
Feature value of sample object for feature f
Feature value of image object for feature f
Standard deviation of the feature values for feature f

The distance in the feature space between a sample object and the image object to be classified is standardized by the standard deviation of all feature values. Thus, features of varying range can be combined in the feature space for classification. Due to the standardization, a distance value of d = 1 means that the distance equals the standard deviation of all feature values of the features defining the feature space.

Based on the distance d a multidimensional, exponential membership function z(d) is computed:

The parameter k determines the decrease of z(d). You can define this parameter with the variable function slope:

The default value for the function slope is 0.2. The smaller the parameter function slope, the narrower the membership function. Image objects have to be closer to sample objects in the feature space to be classified. If the membership value is less than the minimum membership value (default setting 0.1), then the image object is not classified. The following figure demonstrates how the exponential function changes with different function slopes.


Different Membership values for different Function Slopes of the same object for d=1

Defining the Feature Space with Nearest Neighbor Expressions

To define feature spaces, Nearest Neighbor (NN) expressions are used and later applied to classes. eCognition Developer distinguishes between two types of nearest neighbor expressions:


The Edit Standard Nearest Neighbor Feature Space dialog box
  1. From the main menu, choose Classification > Nearest Neighbor > Edit Standard NN Feature Space. The Edit Standard Nearest Neighbor Feature Space dialog box opens
  2. Double-click an available feature to send it to the Selected pane. (Class-related features only become available after an initial classification.)
  3. To remove a feature, double-click it in the Selected pane
  4. Use feature space optimization to combine the best features.

Applying the Standard Nearest Neighbor Classifier


The Apply Standard Nearest Neighbor to Classes dialog box
  1. From the main menu, select Classification > Nearest Neighbor > Apply Standard NN to Classes. The Apply Standard NN to Classes dialog box opens
  2. From the Available classes list on the left, select the appropriate classes by clicking on them
  3. To remove a selected class, click it in the Selected classes list. The class is moved to the Available classes list
  4. Click the All → button to transfer all classes from Available classes to Selected classes. To remove all classes from the Selected classes list, click the ← All button
  5. Click OK to confirm your selection
  6. In the Class Hierarchy window, double-click one class after the other to open the Class Description dialog box and to confirm that the class contains the Standard Nearest Neighbor expression.


The Class Description Dialog Box

The Standard Nearest Neighbor feature space is now defined for the entire project. If you change the feature space in one class description, all classes that contain the Standard Nearest Neighbor expression are affected.

The feature space for both the Nearest Neighbor and the Standard Nearest Neighbor classifier can be edited by double-clicking them in the Class Description dialog box.

Once the Nearest Neighbor classifier has been assigned to all classes, the next step is to collect samples representative of each one.

Interactive Workflow for Nearest Neighbor Classification

Successful Nearest Neighbor classification usually requires several rounds of sample selection and classification. It is most effective to classify a small number of samples and then select samples that have been wrongly classified. Within the feature space, misclassified image objects are usually located near the borders of the general area of this class. Those image objects are the most valuable in accurately describing the feature space region covered by the class. To summarize:

  1. Insert Standard Nearest Neighbor into the class descriptions of classes to be considered
  2. Select samples for each class; initially only one or two per class
  3. Run the classification process. If image objects are misclassified, select more samples out of those and go back to step 2.

Optimizing the Feature Space

Feature Space Optimization is an instrument to help you find the combination of features most suitable for separating classes, in conjunction with a nearest neighbor classifier.

It compares the features of selected classes to find the combination of features that produces the largest average minimum distance between the samples of the different classes.

Using Feature Space Optimization

The Feature Space Optimization dialog box helps you optimize the feature space of a nearest neighbor expression.

To open the Feature Space Optimization dialog box, choose Tools > Feature Space Optimization or Classification > Nearest Neighbor > Feature Space Optimization from the main menu.


The Feature Space Optimization dialog box
  1. To calculate the optimal feature space, press Select Classes to select the classes you want to calculate. Only classes for which you selected sample image objects are available for selection
  2. Click the Select Features button and select an initial set of features, which will later be reduced to the optimal number of features. You cannot use class-related features in the feature space optimization
  3. Highlight single features to select a subset of the initial feature space
  4. Select the image object level for the optimization
  5. Enter the maximum number of features within each combination. A high number reduces the speed of calculation
  6. Click Calculate to generate feature combinations and their distance matrices. (The distance calculation is only based upon samples. Therefore, adding or deleting samples also affects the separability of classes.)
  7. Click Show Distance Matrix to display the Class Separation Distance Matrix for Selected Features dialog box. The matrix is only available after a calculation.
    • The Best Separation Distance between the samples. This value is the minimum overall class combinations, because the overall separation is only as good as the separation of the closest pair of classes.
  8. After calculation, the Optimized Feature Space group box displays the following results:
    • The Dimension indicates the number of features of the best feature combination.
  9. Click Advanced to open the Feature Space Optimization – Advanced Information dialog box and see more details about the results.

TIP: When you change any setting of features or classes, you must first click Calculate before the matrix reflects these changes.


Class Separation Distance Matrix for Selected Features
Viewing Advanced Information

The Feature Space Optimization `– Advanced Information dialog box provides further information about all feature combinations and the separability of the class samples.


The Feature Space Optimization – Advanced Information dialog box
  1. The Result List displays all feature combinations and their corresponding distance values for the closest samples of the classes. The feature space with the highest result is highlighted by default
  2. The Result Chart shows the calculated maximum distances of the closest samples along the dimensions of the feature spaces. The blue dot marks the currently selected feature space
  3. Click the Show Distance Matrix button to display the Class Separation Distance Matrix window. This matrix shows the distances between samples of the selected classes within a selected feature space. Select a feature combination and re-calculate the corresponding distance matrix.


The Class Separation Distance Matrix dialog box
Using the Optimization Results

You can automatically apply the results of your Feature Space Optimization efforts to the project.

  1. In the Feature Space Optimization Advanced Information dialog box, click Apply to Classes to generate a nearest neighbor classifier using the current feature space for selected classes.
  2. Click Apply to Std. NN. to use the currently selected feature space for the Standard Nearest Neighbor classifier.
  3. Check the Classify Project checkbox to automatically classify the project when choosing Apply to Std. NN. or Apply to Classes.

Working with the Sample Editor

The Sample Editor window is the principal tool for inputting samples. For a selected class, it shows histograms of selected features of samples in the currently active map. The same values can be displayed for all image objects at a certain level or all levels in the image object hierarchy.

You can use the Sample Editor window to compare the attributes or histograms of image objects and samples of different classes. It is helpful to get an overview of the feature distribution of image objects or samples of specific classes. The features of an image object can be compared to the total distribution of this feature over one or all image object levels.

Use this tool to assign samples using a Nearest Neighbor classification or to compare an image object to already existing samples, in order to determine to which class an image object belongs. If you assign samples, features can also be compared to the samples of other classes. Only samples of the currently active map are displayed.

It is helpful to open the sample toolbar via View > Toolbars > Samples.

  1. Open the Sample Editor window using Classification > Samples > Sample Editor from the main menu.
  2. By default, the Sample Editor window shows diagrams for only a selection of features. To select the features to be displayed in the Sample Editor, right-click in the Sample Editor window and choose Select Features to Display.
  3. In the Select Displayed Features dialog box, double-click a feature from the left-hand pane to select it. To remove a feature, click it in the right-hand pane.
  4. To add the features used for the Standard Nearest Neighbor expression, select Display Standard Nearest Neighbor Features from the context menu.


The Sample Editor window compares the Active Class and Compare Class with the red arrow indicating the feature value of a selected image object

Comparing Features

To compare samples or layer histograms of two classes, select the classes or the levels you want to compare in the Active Class and Compare Class lists.

Values of the active class are displayed in black in the diagram, the values of the compared class in blue. The value range and standard deviation of the samples are displayed on the right-hand side.

Viewing the Value of an Image Object

When you select an image object, the feature value is highlighted with a red pointer. This enables you to compare different objects with regard to their feature values. The following functions help you to work with the Sample Editor:

In addition, the Sample Editor window allows you to generate membership functions. The following options are available:

Selecting Samples

A Nearest Neighbor classification needs training areas. Therefore, representative samples of image objects need to be collected.

  1. To assign sample objects, activate the input mode. Choose Classification > Samples > Select Samples from the main menu bar. The map view changes to the View Samples mode.
  2. To open the Sample Editor window, which helps to gather adequate sample image objects, do one of the following:
    • Choose Classification > Samples > Sample Editor from the main menu.
    • Choose View > Windows > Sample Editor from the main menu.
  3. To select a class from which you want to collect samples, do one of the following:
    • Select the class in the Class Hierarchy window if available.
    • Select the class from the Active Class drop-down list in the Sample Editor window.
      This makes the selected class your active class so any samples you collect will be assigned to that class.
  4. To define an image object as a sample for a selected class, double-click the image object in the map view. To undo the declaration of an object as sample, double-click it again. You can select or deselect multiple objects by holding down the Shift key.
    As long as the sample input mode is activated, the view will always change back to the Sample View when an image object is selected. Sample View displays sample image objects in the class color; this way the accidental input of samples can be avoided.
  5. To view the feature values of the sample image object, go to the Sample Editor window. This enables you to compare different image objects with regard to their feature values.
  6. Click another potential sample image object for the selected class. Analyze its membership value and its membership distance to the selected class and to all other classes within the feature space. Here you have the following options:
    • The potential sample image object includes new information to describe the selected class: low membership value to selected class, low membership value to other classes.
    • The potential sample image object is really a sample of another class: low membership value to selected class, high membership value to other classes.
    • The potential sample image object is needed as sample to distinguish the selected class from other classes: high membership value to selected class, high membership value to other classes.
      In the first iteration of selecting samples, start with only a few samples for each class, covering the typical range of the class in the feature space. Otherwise, its heterogeneous character will not be fully considered.
  7. Repeat the same for remaining classes of interest.
  8. Classify the scene.
  9. The results of the classification are now displayed in the map view. In the View Settings dialog box, the mode has changed from Samples to Classification.
  10. Note that some image objects may have been classified incorrectly or not at all. All image objects that are classified are displayed in the appropriate class color. If you hover the cursor over a classified image object, a tool -tip pops up indicating the class to which the image object belongs, its membership value, and whether or not it is a sample image object. Image objects that are unclassified appear transparent. If you hover over an unclassified object, a tool-tip indicates that no classification has been applied to this image object. This information is also available in the Classification tab of the Image Object Information window.
  11. The refinement of the classification result is an iterative process:
    • First, assess the quality of your selected samples
    • Then, remove samples that do not represent the selected class well and add samples that are a better match or have previously been misclassified
    • Classify the scene again
    • Repeat this step until you are satisfied with your classification result.
  12. When you have finished collecting samples, remember to turn off the Select Samples input mode. As long as the sample input mode is active, the viewing mode will automatically switch back to the sample viewing mode, whenever an image object is selected. This is to prevent you from accidentally adding samples without taking notice.


Map view with selected samples in View Samples mode. (Image data courtesy of Ministry of Environmental Affairs of Sachsen-Anhalt, Germany.)

Assessing the Quality of Samples

Once a class has at least one sample, the quality of a new sample can be assessed in the Sample Selection Information window. It can help you to decide if an image object contains new information for a class, or if it should belong to another class.


The Sample Selection Information window.
  1. To open the Sample Selection Information window choose Classification > Samples > Sample Selection Information or View > Sample Selection Information from the main menu
  2. Names of classes are displayed in the Class column. The Membership column shows the membership value of the Nearest Neighbor classifier for the selected image object
  3. The Minimum Dist. column displays the distance in feature space to the closest sample of the respective class
  4. The Mean Dist. column indicates the average distance to all samples of the corresponding class
  5. The Critical Samples column displays the number of samples within a critical distance to the selected class in the feature space
  6. The Number of Samples column indicates the number of samples selected for the corresponding class.
    The following highlight colors are used for a better visual overview:
    • Gray: Used for the selected class.
    • Red: Used if a selected sample is critically close to samples of other classes in the feature space.
    • Green: Used for all other classes that are not in a critical relation to the selected class.

The critical sample membership value can be changed by right-clicking inside the window. Select Modify Critical Sample Membership Overlap from the context menu. The default value is 0.7, which means all membership values higher than 0.7 are critical.


The Modify Threshold dialog box

To select which classes are shown, right-click inside the dialog box and choose Select Classes to Display.

Navigating Samples

To navigate to samples in the map view, select samples in the Sample Editor window to highlight them in the map view.

  1. Before navigating to samples you must select a class in the Select Sample Information dialog box.
  2. To activate Sample Navigation , do one of the following:
    • Choose Classification > Samples > Sample Editor Options > Activate Sample Navigation from the main menu
    • Right-click inside the Sample Editor and choose Activate Sample Navigation from the context menu.
  3. To navigate samples, click in a histogram displayed in the Sample Editor window. A selected sample is highlighted in the map view and in the Sample Editor window.
  4. If there are two or more samples so close together that it is not possible to select them separately, you can use one of the following:
    • Select a Navigate to Sample button.
    • Select from the sample selection drop-down list.


For sample navigation choose from a list of similar samples

Deleting Samples

Training and Test Area Masks

Existing samples can be stored in a file called a training and test area (TTA) mask, which allows you to transfer them to other scenes.

To allow mapping samples to image objects, you can define the degree of overlap that a sample image object must show to be considered within in the training area. The TTA mask also contains information about classes for the map. You can use these classes or add them to your existing class hierarchy.

Creating and Saving a TTA Mask


The Create TTA Mask from Samples dialog box
  1. From the main menu select Classification > Samples > Create TTA Mask from Samples
  2. In the dialog box, select the image object level that contains the samples that you want to use for the TTA mask. If your samples are all in one image object level, it is selected automatically and cannot be changed
  3. Click OK to save your changes. Your selection of sample image objects is now converted to a TTA mask
  4. To save the mask to a file, select Classification > Samples > Save TTA Mask. Enter a file name and select your preferred file format.

Loading and Applying a TTA Mask

To load samples from an existing Training and Test Area (TTA) mask:


Apply TTA Mask to Level dialog box
  1. From the main menu select Classification > Samples > Load TTA Mask.
  2. In the Load TTA Mask dialog box, select the desired TTA Mask file and click Open.
  3. In the Load Conversion Table dialog box, open the corresponding conversion table file. The conversion table enables mapping of TTA mask classes to existing classes in the currently displayed map. You can edit the conversion table.
  4. Click Yes to create classes from the conversion table. If your map already contains classes, you can replace them with the classes from the conversion file or add them. If you choose to replace them, your existing class hierarchy will be deleted.
    If you want to retain the class hierarchy, you can save it to a file.
  5. Click Yes to replace the class hierarchy by the classes stored in the conversion table.
  6. To convert the TTA Mask information into samples, select Classification > Samples > Create Samples from TTA Mask. The Apply TTA Mask to Level dialog box opens.
  7. Select which level you want to apply the TTA mask information to. If the project contains only one image object level, this level is preselected and cannot be changed.
  8. In the Create Samples dialog box, enter the Minimum Overlap for Sample Objects and click OK.
    The default value is 0.75. Since a single training area of the TTA mask does not necessarily have to match an image object, the minimum overlap decides whether an image object that is not 100% within a training area in the TTA mask should be declared a sample.
    The value 0.75 indicates that 75% of an image object has to be covered by the sample area for a certain class given by the TTA mask in order for a sample for this class to be generated.
    The map view displays the original map with sample image objects selected where the test area of the TTA mask have been.

The Edit Conversion Table

You can check and edit the linkage between classes of the map and the classes of a Training and Test Area (TTA) mask.

You must edit the conversion table only if you chose to keep your existing class hierarchy and used different names for the classes. A TTA mask has to be loaded and the map must contain classes.


Edit Conversion Table dialog box
  1. To edit the conversion table, choose Classification > Samples > Edit Conversion Table from the main menu
  2. The Linked Class list displays how classes of the map are linked to classes of the TTA mask. To edit the linkage between the TTA mask classes and the classes of the current active map, right-click a TTA mask entry and select the appropriate class from the drop-down list
  3. Choose Link by name to link all identical class names automatically. Choose Unlink all to remove the class links.

Creating Samples Based on a Shapefile

You can use shapefiles to create sample image objects. A shapefile, also called an ESRI shapefile, is a standardized vector file format used to visualize geographic data. You can obtain shapefiles from other geo applications or by exporting them from eCognition maps. A shapefile consists of several individual files such as .shx, .shp and .dbf.

To provide an overview, using a shapefile for sample creation comprises the following steps:

Creating the Samples


Edit a process to use a shapefile
Add a shapefile to an existing project
Add a Parent Process
Add segmentation Child Process

The segmentation finds all objects of the shapefile and converts them to image objects in the thematic layer.

Classify objects using shapefile information

The child process identifies image objects using information from the thematic layer – use the threshold classifier and a feature created from the thematic layer attribute table, for example ‘Image Object ID’ or ‘Class’ from a shapefile ‘Thematic Layer 1’

Converting Objects to samples


Process to import samples from shapefile

Selecting Samples with the Sample Brush

The Sample Brush is an interactive tool that allows you to use your cursor like a brush, creating samples as you sweep it across the map view. Go to the Sample Editor toolbar (View > Toolbars > Sample Editor) and press the Select Sample button. Right-click on the image in map view and select Sample Brush.

Drag the cursor across the scene to select samples. By default, samples are not reselected if the image objects are already classified but existing samples are replaced if drag over them again. These settings can be changed in the Sample Brush group of the Options dialog box. To deselect samples, press Shift as you drag.

The Sample Brush will select up to one hundred image objects at a time, so you may need to increase magnification if you have a large number of image objects.

Setting the Nearest Neighbor Function Slope

The Nearest Neighbor Function Slope defines the distance an object may have from the nearest sample in the feature space while still being classified. Enter values between 0 and 1. Higher values result in a larger number of classified objects.

  1. To set the function slope, choose Classification > Nearest Neighbor > Set NN Function Slope from the main menu bar.
  2. Enter a value and click OK.


The Set Nearest Neighbor Function Slope dialog box

Using Class-Related Features in a Nearest Neighbor Feature Space

To prevent non-deterministic classification results when using class-related features in a nearest neighbor feature space, several constraints have to be mentioned:

Supervised Classification Algorithms (former name 'Classifier')

Overview

The supervised classification algorithm allows classifying based on different statistical classification algorithms:

The algorithm can be applied either pixel- or object-based. For an examples project containing please refer to the eCognition Knowledge-Base and Tutorials.

Bayes

A Bayes classifier is a simple probabilistic classifier based on applying Bayes’ theorem (from Bayesian statistics) with strong independence assumptions. In simple terms, a Bayes classifier assumes that the presence (or absence) of a particular feature of a class is unrelated to the presence (or absence) of any other feature. For example, a fruit may be considered to be an apple if it is red, round, and about 4” in diameter. Even if these features depend on each other or upon the existence of the other features, a Bayes classifier considers all of these properties to independently contribute to the probability that this fruit is an apple. An advantage of the naive Bayes classifier is that it only requires a small amount of training data to estimate the parameters (means and variances of the variables) necessary for classification. Because independent variables are assumed, only the variances of the variables for each class need to be determined and not the entire covariance matrix.

KNN (K Nearest Neighbor)

The k-nearest neighbor algorithm (k-NN) is a method for classifying objects based on closest training examples in the feature space. k-NN is a type of instance-based learning, or lazy learning where the function is only approximated locally and all computation is deferred until classification. The k-nearest neighbor algorithm is amongst the simplest of all machine learning algorithms: an object is classified by a majority vote of its neighbors, with the object being assigned to the class most common amongst its k nearest neighbors (k is a positive integer, typically small). The 5-nearest-neighbor classification rule is to assign to a test sample the majority class label of its 5 nearest training samples. If k = 1, then the object is simply assigned to the class of its nearest neighbor.

This means k is the number of samples to be considered in the neighborhood of an unclassified object/pixel. The best choice of k depends on the data: larger values reduce the effect of noise in the classification, but the class boundaries are less distinct.

eCognition software has the Nearest Neighbor implemented as a classifier that can be applied using the algorithm classifier (KNN with k=1) or using the concept of classification based on the Nearest Neighbor Classification.

SVM (Support Vector Machine)

A support vector machine (SVM) is a concept in computer science for a set of related supervised learning methods that analyze data and recognize patterns, used for classification and regression analysis. The standard SVM takes a set of input data and predicts, for each given input, which of two possible classes the input is a member of. Given a set of training examples, each marked as belonging to one of two categories, an SVM training algorithm builds a model that assigns new examples into one category or the other. An SVM model is a representation of the examples as points in space, mapped so that the examples of the separate categories are pided by a clear gap that is as wide as possible. New examples are then mapped into that same space and predicted to belong to a category based on which side of the gap they fall on. Support Vector Machines are based on the concept of decision planes defining decision boundaries. A decision plane separates between a set of objects having different class memberships.

Important parameters for SVM

There are different kernels that can be used in Support Vector Machines models. Included in eCognition are linear and radial basis function (RBF). The RBF is the most popular choice of kernel types used in Support Vector Machines. Training of the SVM classifier involves the minimization of an error function with C as the capacity constant.

Decision Tree (CART resp. classification and regression tree)

Decision tree learning is a method commonly used in data mining where a series of decisions are made to segment the data into homogeneous subgroups. The model looks like a tree with branches - while the tree can be complex, involving a large number of splits and nodes. The goal is to create a model that predicts the value of a target variable based on several input variables. A tree can be “learned” by splitting the source set into subsets based on an attribute value test. This process is repeated on each derived subset in a recursive manner called recursive partitioning. The recursion is completed when the subset at a node all has the same value of the target variable, or when splitting no longer adds value to the predictions. The purpose of the analyses via tree-building algorithms is to determine a set of if-then logical (split) conditions.

Important Decision Tree parameters

The minimum number of samples that are needed per node are defined by the parameter Min sample count. Finding the right sized tree may require some experience. A tree with too few of splits misses out on improved predictive accuracy, while a tree with too many splits is unnecessarily complicated. Cross validation exists to combat this issue by setting eCognitions parameter Cross validation folds. For a cross-validation the classification tree is computed from the learning sample, and its predictive accuracy is tested by test samples. If the costs for the test sample exceed the costs for the learning sample this indicates poor cross-validation and that a different sized tree might cross-validate better.

Random Trees

The random trees classifier is more a framework that a specific model. It uses an input feature vector and classifies it with every tree in the forest. It results in a class label of the training sample in the terminal node where it ends up. This means the label is assigned that obtained the majority of "votes". Iterating this over all trees results in the random forest prediction. All trees are trained with the same features but on different training sets, which are generated from the original training set. This is done based on the bootstrap procedure: for each training set the same number of vectors as in the original set ( =N ) is selected. The vectors are chosen with replacement which means some vectors will appear more than once and some will be absent. At each node not all variables are used to find the best split but a randomly selected subset of them. For each node a new subset is construced, where its size is fixed for all the nodes and all the trees. It is a training parameter, set to . None of the trees that are built are pruned.

In random trees the error is estimated internally during the training. When the training set for the current tree is drawn by sampling with replacement, some vectors are left out. This data is called out-of-bag data - in short "oob" data. The oob data size is about N/3. The classification error is estimated based on this oob-data.

Classification using the Sample Statistics Table

Overview

The supervised classification algorithm allows a classification based on sample statistics.

As described in the Reference Book > Advanced Classification Algorithms > Update supervised sample statistics and Export supervised sample statistics you can apply statistics generated with eCognition’s algorithms to classify your imagery.

Detailed Workflow

A typical workflow comprises the following steps:

Input of Image Objects for Supervised Sample Statistics


Exemplary class input for sample statistics

 

Generate a Supervised Sample Statistics

 

Exemplary process tree for first sample statistics project

Classification using Sample Statistics

Export a Supervised Sample Statistics Table

Exported sample statistics table

Apply Sample Statistics Table to another Scene


Now the image is classified and the described steps can be repeated based on another scene to refine the sample statistics iteratively.

 

Exemplary process tree for second sample statistics project