create_class_lut_knnT_create_class_lut_knnCreateClassLutKnnCreateClassLutKnncreate_class_lut_knn (算子)

名称

create_class_lut_knnT_create_class_lut_knnCreateClassLutKnnCreateClassLutKnncreate_class_lut_knn — 使用 k-最近邻分类器(k-NN)创建查找表来对字节图像进行分类。

签名

create_class_lut_knn( : : KNNHandle, GenParamName, GenParamValue : ClassLUTHandle)

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

void CreateClassLutKnn(const HTuple& KNNHandle, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* ClassLUTHandle)

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

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

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

static void HOperatorSet.CreateClassLutKnn(HTuple KNNHandle, HTuple genParamName, HTuple genParamValue, out HTuple classLUTHandle)

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

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

HClassLUT HClassKnn.CreateClassLutKnn(HTuple genParamName, HTuple genParamValue)

def create_class_lut_knn(knnhandle: HHandle, gen_param_name: Sequence[str], gen_param_value: Sequence[Union[str, int, float]]) -> HHandle

描述

create_class_lut_knncreate_class_lut_knnCreateClassLutKnnCreateClassLutKnnCreateClassLutKnncreate_class_lut_knn generates a look-up table (LUT) ClassLUTHandleClassLUTHandleClassLUTHandleClassLUTHandleclassLUTHandleclass_luthandle using the data of a trained k-nearest neighbors classifier (k-NN) KNNHandleKNNHandleKNNHandleKNNHandleKNNHandleknnhandle to classify multi-channel byte images. By using this k-NN-based LUT classifier, the operator classify_image_class_knnclassify_image_class_knnClassifyImageClassKnnClassifyImageClassKnnClassifyImageClassKnnclassify_image_class_knn of the subsequent classification can be replaced by the operator classify_image_class_lutclassify_image_class_lutClassifyImageClassLutClassifyImageClassLutClassifyImageClassLutclassify_image_class_lut。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 NumDimNumDimNumDimNumDimnumDimnum_dim of called operator create_class_knncreate_class_knnCreateClassKnnCreateClassKnnCreateClassKnncreate_class_knn is important. The number of image channels the images must have to be classified is defined in NumDimNumDimNumDimNumDimnumDimnum_dim.

To create the LUT, all pixel values are classified with classify_class_knnclassify_class_knnClassifyClassKnnClassifyClassKnnClassifyClassKnnclassify_class_knn。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_knnclassify_image_class_knnClassifyImageClassKnnClassifyImageClassKnnClassifyImageClassKnnclassify_image_class_knn

With 'bit_depth'"bit_depth""bit_depth""bit_depth""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 GenParamNameGenParamNameGenParamNameGenParamNamegenParamNamegen_param_name and GenParamValueGenParamValueGenParamValueGenParamValuegenParamValuegen_param_value:

'bit_depth'"bit_depth""bit_depth""bit_depth""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""bit_depth""bit_depth""bit_depth""bit_depth" <= 8). If the bit depth of the LUT is smaller ('bit_depth'"bit_depth""bit_depth""bit_depth""bit_depth""bit_depth" < 8), 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 pixel combinations, where NumDimNumDimNumDimNumDimnumDimnum_dim denotes the dimension of the LUT, which is specified in create_class_knncreate_class_knnCreateClassKnnCreateClassKnnCreateClassKnncreate_class_knn。For example, for 'bit_depth'"bit_depth""bit_depth""bit_depth""bit_depth""bit_depth" = 7, NumDimNumDimNumDimNumDimnumDimnum_dim = 3, the classes of 8 pixel combinations are mapped in the same LUT entry. The LUT requires at most bytes of storage. For example, for NumDimNumDimNumDimNumDimnumDimnum_dim = 3, 'bit_depth'"bit_depth""bit_depth""bit_depth""bit_depth""bit_depth" = 8 and number of classes is smaller than 16, the LUT requires 8 MB of storage with internal storage optimization. The runtime for the classification in classify_image_class_lutclassify_image_class_lutClassifyImageClassLutClassifyImageClassLutClassifyImageClassLutclassify_image_class_lut becomes minimal if the LUT fits into the cache.

Typical values: 6,7,8

Default: 8

Restriction: 'bit_depth'"bit_depth""bit_depth""bit_depth""bit_depth""bit_depth" >= 1, 'bit_depth'"bit_depth""bit_depth""bit_depth""bit_depth""bit_depth" <= 8.

'rejection_threshold'"rejection_threshold""rejection_threshold""rejection_threshold""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_knnclassify_class_knnClassifyClassKnnClassifyClassKnnClassifyClassKnnclassify_class_knn). All pixels having a distance over 'rejection_threshold'"rejection_threshold""rejection_threshold""rejection_threshold""rejection_threshold""rejection_threshold" are not assigned to any class.

Default: 5

Restriction: 'rejection_threshold'"rejection_threshold""rejection_threshold""rejection_threshold""rejection_threshold""rejection_threshold" >= 0.

执行信息

此算子返回一个句柄。请注意,即使该句柄被用作特定算子的输入参数,这些算子仍可能改变此句柄类型的实例状态。

参数

KNNHandleKNNHandleKNNHandleKNNHandleKNNHandleknnhandle (输入控制)  class_knn HClassKnn, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

k-NN 分类器的句柄。

GenParamNameGenParamNameGenParamNameGenParamNamegenParamNamegen_param_name (输入控制)  attribute.name-array HTupleSequence[str]HTupleHtuple (string) (string) (HString) (char*)

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

默认值: []

建议值: 'bit_depth'"bit_depth""bit_depth""bit_depth""bit_depth""bit_depth", 'rejection_threshold'"rejection_threshold""rejection_threshold""rejection_threshold""rejection_threshold""rejection_threshold"

GenParamValueGenParamValueGenParamValueGenParamValuegenParamValuegen_param_value (输入控制)  attribute.value-array HTupleSequence[Union[str, int, float]]HTupleHtuple (string / integer / real) (string / int / long / double) (HString / Hlong / double) (char* / Hlong / double)

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

默认值: []

建议值: 8, 7, 6, 0.5, 5, 10, 50

ClassLUTHandleClassLUTHandleClassLUTHandleClassLUTHandleclassLUTHandleclass_luthandle (输出控制)  class_lut HClassLUT, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Handle of the LUT classifier.

结果

如果参数有效,算子 create_class_lut_knncreate_class_lut_knnCreateClassLutKnnCreateClassLutKnnCreateClassLutKnncreate_class_lut_knn 返回值 2 ( H_MSG_TRUE )。如有必要,则抛出异常。

可能的前趋

train_class_knntrain_class_knnTrainClassKnnTrainClassKnnTrainClassKnntrain_class_knn, read_class_knnread_class_knnReadClassKnnReadClassKnnReadClassKnnread_class_knn

可能的后继

classify_image_class_lutclassify_image_class_lutClassifyImageClassLutClassifyImageClassLutClassifyImageClassLutclassify_image_class_lut

替代

create_class_lut_svmcreate_class_lut_svmCreateClassLutSvmCreateClassLutSvmCreateClassLutSvmcreate_class_lut_svm, create_class_lut_gmmcreate_class_lut_gmmCreateClassLutGmmCreateClassLutGmmCreateClassLutGmmcreate_class_lut_gmm, create_class_lut_mlpcreate_class_lut_mlpCreateClassLutMlpCreateClassLutMlpCreateClassLutMlpcreate_class_lut_mlp

另见

classify_image_class_lutclassify_image_class_lutClassifyImageClassLutClassifyImageClassLutClassifyImageClassLutclassify_image_class_lut, clear_class_lutclear_class_lutClearClassLutClearClassLutClearClassLutclear_class_lut

模块

基础