Unsupervised KMeans image classification
Brief Description
Unsupervised KMeans image classification
Tags
Learning, Segmentation
Long Description
Performs unsupervised KMeans image classification.KMeansClassification is a composite application, using an existing training and classification application.The SharkKMeans model is used.
KMeansClassification application is only available if OTB is compiled with Shark support(CMake option OTB_USE_SHARK=ON)
The steps of this composite application :
1) ImageEnveloppe : create a shapefile (1 polygon),
2) PolygonClassStatistics : compute the statistics,
3) SampleSelection : select the samples by constant strategy in the shapefile (1000000 samples max),
4) SamplesExtraction : extract the samples descriptors (update of SampleSelection output file),
5) ComputeImagesStatistics : compute images second order statistics,
6) TrainVectorClassifier : train the SharkKMeans model,
7) ImageClassifier : performs the classification of the input image according to a model file.
It's possible to choice random/periodic modes of the SampleSelection application.
If you want keep the temporary files (sample selected, model file, ...), initialize cleanup parameter.
For more information on shark KMeans algorithm [1].
Parameters
Input Image (in): Input image filename.
Output Image (out): Output image containing class labels
Number of classes (nc): Number of modes, which will be used to generate class membership.
Training set size (ts): Size of the training set (in pixels).
Maximum number of iterations (maxit): Maximum number of iterations for the learning step.
Centroid filename (outmeans): Output text file containing centroid positions
Available RAM (Mb) (ram): Available memory for processing (in MB)
Sampler type (sampler): Type of sampling (periodic, pattern based, random)
Periodic sampler (periodic): Takes samples regularly spaced
Jitter amplitude (sampler.periodic.jitter): Jitter amplitude added during sample selection (0 = no jitter)
Random sampler (random): The positions to select are randomly shuffled.
Validity Mask (vm): Validity mask, only non-zero pixels will be used to estimate KMeans modes.
Label mask value (nodatalabel): By default, hidden pixels will have the assigned label 0 in the output image. It's possible to define the label mask by another value, but be careful to not take a label from another class. This application initialize the labels from 0 to N-1, N is the number of class (defined by 'nc' parameter).
Temporary files cleaning (cleanup): If activated, the application will try to clean all temporary files it created
set user defined seed (rand): Set specific seed. with integer value.
Load otb application from xml file (inxml): Load otb application from xml file
Save otb application to xml file (outxml): Save otb application to xml file
Limitations
The application doesn't support NaN in the input image
Authors
OTB-Team
See also
ImageEnveloppe PolygonClassStatistics SampleSelection SamplesExtraction PolygonClassStatistics TrainVectorClassifier ImageClassifier
[1] http://image.diku.dk/shark/sphinx_pages/build/html/rest_sources/tutorials/algorithms/kmeans.html
Example of use
in: QB_1_ortho.tif
ts: 1000
nc: 5
maxit: 1000
out: ClassificationFilterOutput.tif uint8
otbcli_KMeansClassification -in QB_1_ortho.tif -ts 1000 -nc 5 -maxit 1000 -out ClassificationFilterOutput.tif uint8