4.8.6 Unsupervised KMeans image classification

Unsupervised KMeans image classification

Detailed description

Performs unsupervised KMeans image classification.

Parameters

This section describes in details the parameters available for this application. Table 4.122, page 697 presents a summary of these parameters and the parameters keys to be used in command-line and programming languages. Application key is KMeansClassification.





Parameter key

Parameter type

Parameter description




in

Input image

Input Image

out

Output image

Output Image

ram

Int

Available RAM (Mb)

vm

Input image

Validity Mask

ts

Int

Training set size

nc

Int

Number of classes

maxit

Int

Maximum number of iterations

ct

Float

Convergence threshold

outmeans

Output File name

Centroid filename

rand

Int

set user defined seed

inxml

XML input parameters file

Load otb application from xml file

outxml

XML output parameters file

Save otb application to xml file











Table 4.122: Parameters table for Unsupervised KMeans image classification.

Example

To run this example in command-line, use the following:

otbcli_KMeansClassification -in QB_1_ortho.tif -ts 1000 -nc 5 -maxit 1000 -ct 0.0001 -out ClassificationFilterOutput.tif

To run this example from Python, use the following code snippet:

#!/usr/bin/python 
 
# Import the otb applications package 
import otbApplication 
 
# The following line creates an instance of the KMeansClassification application 
KMeansClassification = otbApplication.Registry.CreateApplication("KMeansClassification") 
 
# The following lines set all the application parameters: 
KMeansClassification.SetParameterString("in", "QB_1_ortho.tif") 
 
KMeansClassification.SetParameterInt("ts", 1000) 
 
KMeansClassification.SetParameterInt("nc", 5) 
 
KMeansClassification.SetParameterInt("maxit", 1000) 
 
KMeansClassification.SetParameterFloat("ct", 0.0001) 
 
KMeansClassification.SetParameterString("out", "ClassificationFilterOutput.tif") 
 
# The following line execute the application 
KMeansClassification.ExecuteAndWriteOutput()

Limitations

None

Authors

This application has been written by OTB-Team.