Classifying Images


One very common task concerning images is classification. In order to use the images for mapping or further analysis, it is often interesting to translate the frequency information contained in images into thematic information such as land use or state of vegetation. You generally have the choice between two approaches: supervised or unsupervised image classification.

Unsupervised classification

Unsupervised classification consists of letting the computer automatically calculate classes on the basis of several (more than one) frequency bands of you image. This leaves you with the task of identifying the right number and the real world meaning of the resulting classes. For unsupervised classification go through the following steps:

creation of group and subgroup

If not already done, you have to create a group and a subgroup containing the files you wish to classify. Use to do so.


Use i.cluster to create the classes from your images. The man page explains all the parameters. You can optionally give a seed signature file to i.cluster which contains definitions of classes resulting from a previous clustering session or from a supervised clustering procedure. This seed file should help you optimize the cluster decision boundaries.


Now that you have created your class definitions, you have to reclassify your original image to decide to which class each individual pixel belongs. As always (well, almost always), GRASS has a solution for you: i.maxlik, a "maximum-likelihood discriminant analysis classifier". This takes the signature file ("sigfile") generated by i.cluster to assign each pixel to a class based on probabilities of likelihood. The resulting map will show you the classes in your original map. The optional "reject" parameter allows you to create a raster map containing the confidence levels for each pixel.

Supervised classification

In supervised classification you do not let the computer create the classes, but you create them yourself and let the computer only do the second step, i.e. the assignment of pixels to the classes. This means that you determine beforehand the number and the nature of the classes you wish to use. Follow these steps for supervised classification:

creating the classes

GRASS allows you to create the classes by determining so-called "training areas" in existing maps. Such training-areas have to represent a homogenous sample for them to work. The module i.class helps you in defining those areas. It lets you display a map (such as, for example, a color composite created with i.composite) and identify homogenous areas in this map. The spectral signatures of these areas will then be saved and can then be used as classes in i.maxlik.


This is the same as for the unsupervised classification: use i.maxlik for this step.

Partially supervised classification

An intermediate path between the two above option is the use of i.gensig. This module crates the spectral signatures automatically for you, based on a training map you provide. This training map should contain already classified training areas. You can create a training map using v.digit or r.digit or by extracting relevant features with v.extract or r.mapcalc.