ClassesClasses | | Operators

classify_image_class_knnT_classify_image_class_knnClassifyImageClassKnnClassifyImageClassKnn (Operator)

Name

classify_image_class_knnT_classify_image_class_knnClassifyImageClassKnnClassifyImageClassKnn — Classify an image with a k-Nearest-Neighbor classifier.

Signature

classify_image_class_knn(Image : ClassRegions, DistanceImage : KNNHandle, RejectionThreshold : )

Herror T_classify_image_class_knn(const Hobject Image, Hobject* ClassRegions, Hobject* DistanceImage, const Htuple KNNHandle, const Htuple RejectionThreshold)

void ClassifyImageClassKnn(const HObject& Image, HObject* ClassRegions, HObject* DistanceImage, const HTuple& KNNHandle, const HTuple& RejectionThreshold)

HRegion HImage::ClassifyImageClassKnn(HImage* DistanceImage, const HClassKnn& KNNHandle, double RejectionThreshold) const

HRegion HClassKnn::ClassifyImageClassKnn(const HImage& Image, HImage* DistanceImage, double RejectionThreshold) const

static void HOperatorSet.ClassifyImageClassKnn(HObject image, out HObject classRegions, out HObject distanceImage, HTuple KNNHandle, HTuple rejectionThreshold)

HRegion HImage.ClassifyImageClassKnn(out HImage distanceImage, HClassKnn KNNHandle, double rejectionThreshold)

HRegion HClassKnn.ClassifyImageClassKnn(HImage image, out HImage distanceImage, double rejectionThreshold)

Description

classify_image_class_knnclassify_image_class_knnClassifyImageClassKnnClassifyImageClassKnnClassifyImageClassKnn performs a pixel classification with a k-Nearest-Neighbor classifier (k-NN) KNNHandleKNNHandleKNNHandleKNNHandleKNNHandle on the multichannel image ImageImageImageImageimage. Before calling classify_image_class_knnclassify_image_class_knnClassifyImageClassKnnClassifyImageClassKnnClassifyImageClassKnn the k-NN classifier must be trained with train_class_knntrain_class_knnTrainClassKnnTrainClassKnnTrainClassKnn. ImageImageImageImageimage must have NumDimNumDimNumDimNumDimnumDim channels, as specified with create_class_knncreate_class_knnCreateClassKnnCreateClassKnnCreateClassKnn. On output, ClassRegionsClassRegionsClassRegionsClassRegionsclassRegions contains NumClassesNumClassesNumClassesNumClassesnumClasses regions as the result of the classification. Note that the order of the regions that are returned in ClassRegionsClassRegionsClassRegionsClassRegionsclassRegions corresponds to the order of the classes as defined by the training regions in add_samples_image_class_knnadd_samples_image_class_knnAddSamplesImageClassKnnAddSamplesImageClassKnnAddSamplesImageClassKnn. The parameter RejectionThresholdRejectionThresholdRejectionThresholdRejectionThresholdrejectionThreshold can be used to reject pixels that have an uncertain classification. RejectionThresholdRejectionThresholdRejectionThresholdRejectionThresholdrejectionThreshold represents a threshold on the distance to the nearest neighbor returned by the classification. All pixels having a probability below RejectionThresholdRejectionThresholdRejectionThresholdRejectionThresholdrejectionThreshold are not assigned to any class. DistanceImageDistanceImageDistanceImageDistanceImagedistanceImage contains the distance of each pixel to its nearest neighbor.

Execution Information

Parameters

ImageImageImageImageimage (input_object)  (multichannel-)image objectHImageHImageHobject (byte / cyclic / direction / int1 / int2 / uint2 / int4 / real)

Input image.

ClassRegionsClassRegionsClassRegionsClassRegionsclassRegions (output_object)  region-array objectHRegionHRegionHobject * (real)

Segmented classes.

DistanceImageDistanceImageDistanceImageDistanceImagedistanceImage (output_object)  image objectHImageHImageHobject *

Distance of the pixel's nearest neighbor.

KNNHandleKNNHandleKNNHandleKNNHandleKNNHandle (input_control)  class_knn HClassKnn, HTupleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Handle of the k-NN classifier.

RejectionThresholdRejectionThresholdRejectionThresholdRejectionThresholdrejectionThreshold (input_control)  real HTupleHTupleHtuple (real) (double) (double) (double)

Threshold for the rejection of the classification.

Default value: 0.5

Suggested values: 0.0, 0.1, 0.2, 0.3, 5.0, 10.0, 255.0

Restriction: RejectionThreshold >= 0.0

Example (HDevelop)

read_image (Image, 'ic')
gen_rectangle1 (Board, 80, 320, 110, 350)
gen_rectangle1 (Capacitor, 359, 263, 371, 302)
gen_rectangle1 (Resistor, 200, 252, 290, 256)
gen_rectangle1 (IC, 180, 135, 216, 165)
concat_obj (Board, Capacitor, Classes)
concat_obj (Classes, Resistor, Classes)
concat_obj (Classes, IC, Classes)
create_class_knn (3, KNNHandle)
add_samples_image_class_knn (Image, Classes, KNNHandle)
get_sample_num_class_knn (KNNHandle, NumSamples)
train_class_knn (KNNHandle, [], [])
classify_image_class_knn (Image, ClassRegions, DistanceImage, KNNHandle, 0.5)
dev_display (ClassRegions)

Result

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

Possible Predecessors

train_class_knntrain_class_knnTrainClassKnnTrainClassKnnTrainClassKnn, read_class_knnread_class_knnReadClassKnnReadClassKnnReadClassKnn

Alternatives

classify_image_class_svmclassify_image_class_svmClassifyImageClassSvmClassifyImageClassSvmClassifyImageClassSvm, classify_image_class_mlpclassify_image_class_mlpClassifyImageClassMlpClassifyImageClassMlpClassifyImageClassMlp, classify_image_class_gmmclassify_image_class_gmmClassifyImageClassGmmClassifyImageClassGmmClassifyImageClassGmm, classify_image_class_lutclassify_image_class_lutClassifyImageClassLutClassifyImageClassLutClassifyImageClassLut, class_ndim_normclass_ndim_normClassNdimNormClassNdimNormClassNdimNorm, class_2dim_supclass_2dim_supClass2dimSupClass2dimSupClass2dimSup

See also

add_samples_image_class_knnadd_samples_image_class_knnAddSamplesImageClassKnnAddSamplesImageClassKnnAddSamplesImageClassKnn, create_class_knncreate_class_knnCreateClassKnnCreateClassKnnCreateClassKnn

Module

Foundation


ClassesClasses | | Operators