classify_image_class_knnT_classify_image_class_knnClassifyImageClassKnnClassifyImageClassKnnclassify_image_class_knn (Operator)
Name
classify_image_class_knnT_classify_image_class_knnClassifyImageClassKnnClassifyImageClassKnnclassify_image_class_knn
— Classify an image with a k-Nearest-Neighbor classifier.
Signature
Description
classify_image_class_knnclassify_image_class_knnClassifyImageClassKnnClassifyImageClassKnnClassifyImageClassKnnclassify_image_class_knn
performs a pixel classification
with a k-Nearest-Neighbor classifier (k-NN) KNNHandleKNNHandleKNNHandleKNNHandleKNNHandleknnhandle
on the
multichannel image ImageImageImageImageimageimage
. Before calling
classify_image_class_knnclassify_image_class_knnClassifyImageClassKnnClassifyImageClassKnnClassifyImageClassKnnclassify_image_class_knn
the k-NN classifier must be trained with
train_class_knntrain_class_knnTrainClassKnnTrainClassKnnTrainClassKnntrain_class_knn
. ImageImageImageImageimageimage
must have NumDimNumDimNumDimNumDimnumDimnum_dim
channels, as specified with create_class_knncreate_class_knnCreateClassKnnCreateClassKnnCreateClassKnncreate_class_knn
. On output,
ClassRegionsClassRegionsClassRegionsClassRegionsclassRegionsclass_regions
contains NumClassesNumClassesNumClassesNumClassesnumClassesnum_classes
regions as the
result of the classification. Note
that the order of the regions that are returned in
ClassRegionsClassRegionsClassRegionsClassRegionsclassRegionsclass_regions
corresponds to the order of the classes as
defined by the training regions in
add_samples_image_class_knnadd_samples_image_class_knnAddSamplesImageClassKnnAddSamplesImageClassKnnAddSamplesImageClassKnnadd_samples_image_class_knn
. The parameter
RejectionThresholdRejectionThresholdRejectionThresholdRejectionThresholdrejectionThresholdrejection_threshold
can be used to reject pixels that have
an uncertain classification. RejectionThresholdRejectionThresholdRejectionThresholdRejectionThresholdrejectionThresholdrejection_threshold
represents
a threshold on the distance to the nearest neighbor returned by the
classification. All pixels having a probability below
RejectionThresholdRejectionThresholdRejectionThresholdRejectionThresholdrejectionThresholdrejection_threshold
are not assigned to any class.
DistanceImageDistanceImageDistanceImageDistanceImagedistanceImagedistance_image
contains the distance of each pixel to its nearest
neighbor.
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.
Parameters
ImageImageImageImageimageimage
(input_object) (multichannel-)image →
objectHImageHObjectHImageHobject (byte / cyclic / direction / int1 / int2 / uint2 / int4 / real)
Input image.
ClassRegionsClassRegionsClassRegionsClassRegionsclassRegionsclass_regions
(output_object) region-array →
objectHRegionHObjectHRegionHobject * (real)
Segmented classes.
DistanceImageDistanceImageDistanceImageDistanceImagedistanceImagedistance_image
(output_object) image →
objectHImageHObjectHImageHobject *
Distance of the pixel's nearest neighbor.
KNNHandleKNNHandleKNNHandleKNNHandleKNNHandleknnhandle
(input_control) class_knn →
HClassKnn, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)
Handle of the k-NN classifier.
RejectionThresholdRejectionThresholdRejectionThresholdRejectionThresholdrejectionThresholdrejection_threshold
(input_control) real →
HTuplefloatHTupleHtuple (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_knnClassifyImageClassKnnClassifyImageClassKnnClassifyImageClassKnnclassify_image_class_knn
returns the value 2 (H_MSG_TRUE). If
necessary an exception is raised.
Possible Predecessors
train_class_knntrain_class_knnTrainClassKnnTrainClassKnnTrainClassKnntrain_class_knn
,
read_class_knnread_class_knnReadClassKnnReadClassKnnReadClassKnnread_class_knn
Alternatives
classify_image_class_svmclassify_image_class_svmClassifyImageClassSvmClassifyImageClassSvmClassifyImageClassSvmclassify_image_class_svm
,
classify_image_class_mlpclassify_image_class_mlpClassifyImageClassMlpClassifyImageClassMlpClassifyImageClassMlpclassify_image_class_mlp
,
classify_image_class_gmmclassify_image_class_gmmClassifyImageClassGmmClassifyImageClassGmmClassifyImageClassGmmclassify_image_class_gmm
,
classify_image_class_lutclassify_image_class_lutClassifyImageClassLutClassifyImageClassLutClassifyImageClassLutclassify_image_class_lut
,
class_ndim_normclass_ndim_normClassNdimNormClassNdimNormClassNdimNormclass_ndim_norm
,
class_2dim_supclass_2dim_supClass2dimSupClass2dimSupClass2dimSupclass_2dim_sup
See also
add_samples_image_class_knnadd_samples_image_class_knnAddSamplesImageClassKnnAddSamplesImageClassKnnAddSamplesImageClassKnnadd_samples_image_class_knn
,
create_class_knncreate_class_knnCreateClassKnnCreateClassKnnCreateClassKnncreate_class_knn
Module
Foundation