-
ClaskNN: Classifier by number of nearest neighbors
Direct access to online help: ClaskNN
Access the application from the menu: "Tools | Image classification | Number of nearest neighbors (kNN) classifier"
Presentation and options
This application performs a supervised classification of an image (monoband or multiband) using the kNN method. kNN is the acronym for k (which refers to a preset number of pixels from the pixels used to define the desired classes on the categorical map to be obtained) and NN (nearest neighbors). The method assumes that it is plausible that the pixels that are close to each other in the statistical space belong to the same informational class.
For each pixel of the image to be classified, the Euclidean distance (on the statistical space of representation of the independent variables) is calculated to each pixel of the training areas. The k nearest training areas pixels are chosen and the predominant class of this group of pixels is the class that is assigned to the pixel to be classified. To calculate the dominant class, two options are allowed: the first by mode and the second applying a weight according to the inverse of the distance (that is to say, in the mode calculation the nearest values in the statistical space weigh more). Input files must be in IMG raster format and data type can be any of those supported by MiraMon. More information can be consulted at MiraMon raster formats description.
In contrast to other classifiers, in which the number of samples used to define classes is not relevant in the allocation phase, the more samples exist, the significantly slower kNN classification is.
By default, this application loads all images in memory, which allows performing processes in a more agile way. However, in computers with a few resources regarding the size of images, this strategy could be unviable. Due to this, the option "Do not upload images in memory" allows indicating the program that in the processes it keeps in memory only those data needed in each moment, nor that implies a slowdown of the running. The application commutes automatically to this mode if it does not have enough available memory, so usually, there is no need to activate it specifically.
This application is parallelized, both in versions of 32 and 64 bits, so it is possible that it distributes the work between the available processor cores in the computer where it runs. For example, in a computer that has two processors of 20 cores each, the time needed to obtain the results can be divided almost into 40 by using all available cores, which can be done with the corresponding parameter stated by "MAX"; when the number of cores to use is MAX, the applicacion uses all the cores. Nevertheless, sometimes the choice of not compromising the whole capacity of the computer calculations can be preferred, stating SUB_MAX (which will leave a free processor for other performed tasks) or by choosing a concrete inferior numerical value, in all cases through the option "Number of processor cores to be used". Asking for more cores than the actually available is also possible, creating other virtual ones, but this does not speed the procedure, but on the contrary. The Windows Task Manager allows knowing the total number of cores of the computer, and it also can be known by running the application in MAX mode, because it will state on-screen how many cores is using.

Dialog box of the application

Syntax
Syntax:
- ClaskNN CalculationType ListofIMGfiles ClassFile TAfile NumNeighbors [/MaxDist] [/NVeinsMin] [/MaxBandesNODATA] [/AEAmbNODATA] [/PertMax] [/VariablesAE] [/DISC] [/N_Proces] [/2_CLASSES_RESULT] /MapaDistMin /MapaDistMax /MapaMedianDist /MapaNPixAE /MapaIncert /MapaFKM
Parameters:
- CalculationType
(Calculation type -
Input parameter): Method of calculation of the predominant class:
- 2 Using the mode after applying a weight relative to the inverse of the distance.
- ListofIMGfiles
(List of input raster files -
Input parameter): List of raster input files.
- ClassFile
(Output file -
Output parameter): Output file of the classification.
- TAfile
(Training areas file -
Input parameter): Training areas file.
- NumNeighbors
(Number of neighbors -
Input parameter): Parameter of the number of nearest neighbors (algorithm k value).
Modifiers:
/MaxDist=
(Maximum distance to be a candidate as one of the k neighbors)
Maximum distance over which a pixel in a training area cannot be a candidate to become one of the k neighbors. (Input parameter) /NVeinsMin=
(Minimum number of neighbors to classify a pixel)
Minimum number of neighbors to classify a pixel. (Input parameter) /MaxBandesNODATA=
(Tolerance of variables with NoData)
Maximum number of variables with a NoData value to classify a pixel and not considering it as NoData. State MAX to use the maximum limit. If the special MAX parameter is indicated, it automatically classifies with this parameter initialized to the number of bands minus 1. On the contrary, if the parameter is not indicated, it is equivalent to indicating a 0 (that is, that only a single data is missing in the multivariate set, the pixel is not classified). (Input parameter) /AEAmbNODATA
(Accept training areas with NoData)
Accept training areas with NoData in any of the variables. (Input parameter) /PertMax=
(Maximum membership)
Maximum membership to calculate the uncertainty map. Only applies if MapaFKM or MapaIncert is requested. It can be defined by the addition of the pixel memberships (default value) or a value defined by the user. (Input parameter) /VariablesAE=
(Training areas variables list)
Variables list where the values of the training areas can be read in order to make the classification. If not stated, the input variables will be used (the ones of the 'FileAE' parameter). (Input parameter) /DISC
(Forced to not to load the images to classify in memory)
Useful for computers with low memory related to the size of the files to be used for the classification. Generally there is no need to apply it because if the program runs out of memory, it commutes this mode automatically. (Input parameter) /N_Proces=
(Number of processor cores to use)
A concrete number of processors can be stated or "MAX" (to use all the processors), or "SUB_MAX" (to use all the processors except one). (Input parameter) /2_CLASSES_RESULT
(Generate raster classification at second instance)
Generate a second raster with the classification result in second instance. (Input parameter) /MapaDistMin=
(Map of minimum distance)
Map of the minimum distance to the training areas with which the decision to classify the pixel in a particular class has been taken. (Output parameter) /MapaDistMax=
(Map of maximum distance)
Map of the maximum distance to the training areas with which the decision to classify the pixel in a particular class has been taken. (Output parameter) /MapaMedianDist=
(Map of the median of distances)
Maps of the median distances to the training areas with which the decision to classify the pixel in a particular class has been taken. (Output parameter) /MapaNPixAE=
(Map of the number of neighbors of the training areas)
Map of the number of neighbors used in the training areas. (Output parameter) /MapaIncert=
(Map of uncertainty)
Map of uncertainty. (Output parameter) /MapaFKM=
(Map of fuzzy k-means)
Map of fuzzy k-means (similar to the uncertainty map). (Output parameter)
