Skip to content

create_class_lut_knnCreateClassLutKnnCreateClassLutKnncreate_class_lut_knnT_create_class_lut_knn🔗

Short description🔗

create_class_lut_knnCreateClassLutKnnCreateClassLutKnncreate_class_lut_knnT_create_class_lut_knn — Create a look-up table using a k-nearest neighbors classifier (k-NN) to classify byte images.

Signature🔗

create_class_lut_knn( class_knn KNNHandle, attribute.name GenParamName, attribute.value GenParamValue, out class_lut ClassLUTHandle )void CreateClassLutKnn( const HTuple& KNNHandle, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* ClassLUTHandle )static void HOperatorSet.CreateClassLutKnn( HTuple KNNHandle, HTuple genParamName, HTuple genParamValue, out HTuple classLUTHandle )def create_class_lut_knn( knnhandle: HHandle, gen_param_name: Sequence[str], gen_param_value: Sequence[Union[str, int, float]] ) -> HHandle

Herror T_create_class_lut_knn( const Htuple KNNHandle, const Htuple GenParamName, const Htuple GenParamValue, Htuple* ClassLUTHandle )

void HClassLUT::HClassLUT( const HClassKnn& KNNHandle, const HTuple& GenParamName, const HTuple& GenParamValue )

public HClassLUT( HClassKnn KNNHandle, HTuple genParamName, HTuple genParamValue )

void HClassLUT::CreateClassLutKnn( const HClassKnn& KNNHandle, const HTuple& GenParamName, const HTuple& GenParamValue )

HClassLUT HClassKnn::CreateClassLutKnn( const HTuple& GenParamName, const HTuple& GenParamValue ) const

void HClassLUT.CreateClassLutKnn( HClassKnn KNNHandle, HTuple genParamName, HTuple genParamValue )

HClassLUT HClassKnn.CreateClassLutKnn( HTuple genParamName, HTuple genParamValue )

Description🔗

create_class_lut_knnCreateClassLutKnn generates a look-up table (LUT) ClassLUTHandleclassLUTHandleclass_luthandle using the data of a trained k-nearest neighbors classifier (k-NN) KNNHandleKNNHandleknnhandle to classify multi-channel byte images. By using this k-NN-based LUT classifier, the operator classify_image_class_knnClassifyImageClassKnn of the subsequent classification can be replaced by the operator classify_image_class_lutClassifyImageClassLut. The classification is speed up considerably, because the estimation of the class in every image point is no longer necessary since every possible response of the k-NN is stored in the LUT. For the generation of the LUT, the parameter NumDimnumDimnum_dim of called operator create_class_knnCreateClassKnn is important. The number of image channels the images must have to be classified is defined in NumDimnumDimnum_dim.

To create the LUT, all pixel values are classified with classify_class_knnClassifyClassKnn. The returned classes are stored in the LUT. Because of the discretization of the LUT, the accuracy of the LUT classifier could become lower than the accuracy of classify_image_class_knnClassifyImageClassKnn.

With 'bit_depth'"bit_depth" the accuracy of the classification, the required storage, and the runtime needed to create the LUT can be controlled.

The following parameters of the k-NN-based LUT classifier can be set with GenParamNamegenParamNamegen_param_name and GenParamValuegenParamValuegen_param_value:

  • 'bit_depth'"bit_depth": Number of bits used from the pixels. It controls the storage requirement of the LUT classifier and is bounded by the bit depth of the image ('bit_depth'"bit_depth" \(<=\) 88). If the bit depth of the LUT is smaller ('bit_depth'"bit_depth" \(<\) 88), the classes of multiple pixel combinations will be mapped to the same LUT entry, which can result in a lower accuracy for the classification. One of these clusters contains \(2^{NumDim \cdot (8-bit\_depth)}\) pixel combinations, where NumDimnumDimnum_dim denotes the dimension of the LUT, which is specified in create_class_knnCreateClassKnn. For example, for 'bit_depth'"bit_depth" \(=\) 77, NumDimnumDimnum_dim \(=\) 33, the classes of 8 pixel combinations are mapped in the same LUT entry. The LUT requires at most \(2^{NumDim \cdot bit\_depth+2}\) bytes of storage. For example, for NumDimnumDimnum_dim \(=\) 33, 'bit_depth'"bit_depth" \(=\) 88 and number of classes is smaller than 1616, the LUT requires 8 MB of storage with internal storage optimization. The runtime for the classification in classify_image_class_lutClassifyImageClassLut becomes minimal if the LUT fits into the cache.

    Suggested values: 66,77,88

    Default: 88

    Restriction: 'bit_depth'"bit_depth" \(>=\) 11, 'bit_depth'"bit_depth" \(<=\) 88.

  • 'rejection_threshold'"rejection_threshold": Threshold for the rejection of uncertain classified points of the k-NN. The parameter represents a threshold on the distance returned by the classification (see classify_class_knnClassifyClassKnn). All pixels having a distance over 'rejection_threshold'"rejection_threshold" are not assigned to any class.

    Default: 55

    Restriction: 'rejection_threshold'"rejection_threshold" \(>=\) 00.

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Automatically parallelized on internal data level.

This operator returns a handle. Note that the state of an instance of this handle type may be changed by specific operators even though the handle is used as an input parameter by those operators.

Parameters🔗

KNNHandleKNNHandleknnhandle (input_control) class_knn → (handle)HTuple (HHandle)HClassKnn, HTuple (IntPtr)HHandleHtuple (handle)

Handle of the k-NN classifier.

GenParamNamegenParamNamegen_param_name (input_control) attribute.name-array → (string)HTuple (HString)HTuple (string)Sequence[str]Htuple (char*)

Names of the generic parameters that can be adjusted for the LUT classifier creation.

Default: [][]
Suggested values: 'bit_depth', 'rejection_threshold'"bit_depth", "rejection_threshold"

GenParamValuegenParamValuegen_param_value (input_control) attribute.value-array → (string / integer / real)HTuple (HString / Hlong / double)HTuple (string / int / long / double)Sequence[Union[str, int, float]]Htuple (char* / Hlong / double)

Values of the generic parameters that can be adjusted for the LUT classifier creation.

Default: [][]
Suggested values: 8, 7, 6, 0.5, 5, 10, 508, 7, 6, 0.5, 5, 10, 50

ClassLUTHandleclassLUTHandleclass_luthandle (output_control) class_lut → (handle)HTuple (HHandle)HClassLUT, HTuple (IntPtr)HHandleHtuple (handle)

Handle of the LUT classifier.

Result🔗

If the parameters are valid, the operator create_class_lut_knnCreateClassLutKnn returns the value 2 (H_MSG_TRUE). If necessary an exception is raised.

Combinations with other operators🔗

Combinations

Possible predecessors

train_class_knnTrainClassKnn, read_class_knnReadClassKnn

Possible successors

classify_image_class_lutClassifyImageClassLut

Alternatives

create_class_lut_svmCreateClassLutSvm, create_class_lut_gmmCreateClassLutGmm, create_class_lut_mlpCreateClassLutMlp

See also

classify_image_class_lutClassifyImageClassLut, clear_class_lutClearClassLut

Module🔗

Foundation