Skip to content

add_samples_image_class_svmAddSamplesImageClassSvmAddSamplesImageClassSvmadd_samples_image_class_svmT_add_samples_image_class_svm🔗

Short description🔗

add_samples_image_class_svmAddSamplesImageClassSvmAddSamplesImageClassSvmadd_samples_image_class_svmT_add_samples_image_class_svm — Add training samples from an image to the training data of a support vector machine.

Signature🔗

add_samples_image_class_svm( image Image, region ClassRegions, class_svm SVMHandle )void AddSamplesImageClassSvm( const HObject& Image, const HObject& ClassRegions, const HTuple& SVMHandle )static void HOperatorSet.AddSamplesImageClassSvm( HObject image, HObject classRegions, HTuple SVMHandle )def add_samples_image_class_svm( image: HObject, class_regions: HObject, svmhandle: HHandle ) -> None

Herror T_add_samples_image_class_svm( const Hobject Image, const Hobject ClassRegions, const Htuple SVMHandle )

void HImage::AddSamplesImageClassSvm( const HRegion& ClassRegions, const HClassSvm& SVMHandle ) const

void HClassSvm::AddSamplesImageClassSvm( const HImage& Image, const HRegion& ClassRegions ) const

void HImage.AddSamplesImageClassSvm( HRegion classRegions, HClassSvm SVMHandle )

void HClassSvm.AddSamplesImageClassSvm( HImage image, HRegion classRegions )

Description🔗

add_samples_image_class_svmAddSamplesImageClassSvm adds training samples from the image Imageimageimage to the support vector machine (SVM) given by SVMHandleSVMHandlesvmhandle. add_samples_image_class_svmAddSamplesImageClassSvm is used to store the training samples before training a classifier for the pixel classification of multichannel images with classify_image_class_svmClassifyImageClassSvm. add_samples_image_class_svmAddSamplesImageClassSvm works analogously to add_sample_class_svmAddSampleClassSvm.

The image Imageimageimage must have a number of channels equal to NumFeaturesnumFeaturesnum_features, as specified with create_class_svmCreateClassSvm. The training regions for the NumClassesnumClassesnum_classes pixel classes are passed in ClassRegionsclassRegionsclass_regions. Hence, ClassRegionsclassRegionsclass_regions must be a tuple containing NumClassesnumClassesnum_classes regions. The order of the regions in ClassRegionsclassRegionsclass_regions determines the class of the pixels. If there are no samples for a particular class in Imageimageimage, an empty region must be passed at the position of the class in ClassRegionsclassRegionsclass_regions. With this mechanism it is possible to use multiple images to add training samples for all relevant classes to the SVM by calling add_samples_image_class_svmAddSamplesImageClassSvm multiple times with the different images and suitably chosen regions.

The regions in ClassRegionsclassRegionsclass_regions should contain representative training samples for the respective classes. Hence, they need not cover the entire image. The regions in ClassRegionsclassRegionsclass_regions should not overlap each other, because this would lead to the fact that in the training data the samples from the overlapping areas would be assigned to multiple classes, which may lead to slower convergence of the training and a lower classification performance.

A further application of this operator is the automatic novelty detection, where, e.g., anomalies in color or texture can be detected. For this mode a training set that defines a sample region (e.g., skin regions for skin detection or samples of the correct texture) is passed to the SVMHandleSVMHandlesvmhandle, which is created in the Mode 'novelty-detection'"novelty-detection". After training, regions that differ from the trained sample regions are detected (e.g., the rejection class for skin or errors in texture).

Execution information🔗

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

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

  • Processed without parallelization.

This operator modifies the state of the following input parameter:

During execution of this operator, access to the value of this parameter must be synchronized if it is used across multiple threads.

Parameters🔗

Imageimageimage (input_object) (multichannel-)image → object (byte / cyclic / direction / int1 / int2 / uint2 / int4 / real)HObject (byte / cyclic / direction / int1 / int2 / uint2 / int4 / real)HImage (byte / cyclic / direction / int1 / int2 / uint2 / int4 / real)HObject (byte / cyclic / direction / int1 / int2 / uint2 / int4 / real)Hobject (byte / cyclic / direction / int1 / int2 / uint2 / int4 / real)

Training image.

ClassRegionsclassRegionsclass_regions (input_object) region-array → objectHObjectHRegionHObjectHobject

Regions of the classes to be trained.

SVMHandleSVMHandlesvmhandle (input_control, state is modified) class_svm → (handle)HTuple (HHandle)HClassSvm, HTuple (IntPtr)HHandleHtuple (handle)

SVM handle.

Result🔗

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

Combinations with other operators🔗

Combinations

Possible predecessors

create_class_svmCreateClassSvm

Possible successors

train_class_svmTrainClassSvm, write_samples_class_svmWriteSamplesClassSvm

Alternatives

read_samples_class_svmReadSamplesClassSvm

See also

classify_image_class_svmClassifyImageClassSvm, add_sample_class_svmAddSampleClassSvm, clear_samples_class_svmClearSamplesClassSvm, get_sample_num_class_svmGetSampleNumClassSvm, get_sample_class_svmGetSampleClassSvm, add_samples_image_class_mlpAddSamplesImageClassMlp

Module🔗

Foundation