get_prep_info_ocr_class_svmT_get_prep_info_ocr_class_svmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvm (Operator)

Name

get_prep_info_ocr_class_svmT_get_prep_info_ocr_class_svmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvm — Berechnung des Informationsgehaltes der vorverarbeiteten Merkmalsvektoren eines OCR-Klassifikators.

Signatur

get_prep_info_ocr_class_svm( : : OCRHandle, TrainingFile, Preprocessing : InformationCont, CumInformationCont)

Herror T_get_prep_info_ocr_class_svm(const Htuple OCRHandle, const Htuple TrainingFile, const Htuple Preprocessing, Htuple* InformationCont, Htuple* CumInformationCont)

void GetPrepInfoOcrClassSvm(const HTuple& OCRHandle, const HTuple& TrainingFile, const HTuple& Preprocessing, HTuple* InformationCont, HTuple* CumInformationCont)

HTuple HOCRSvm::GetPrepInfoOcrClassSvm(const HTuple& TrainingFile, const HString& Preprocessing, HTuple* CumInformationCont) const

HTuple HOCRSvm::GetPrepInfoOcrClassSvm(const HString& TrainingFile, const HString& Preprocessing, HTuple* CumInformationCont) const

HTuple HOCRSvm::GetPrepInfoOcrClassSvm(const char* TrainingFile, const char* Preprocessing, HTuple* CumInformationCont) const

HTuple HOCRSvm::GetPrepInfoOcrClassSvm(const wchar_t* TrainingFile, const wchar_t* Preprocessing, HTuple* CumInformationCont) const   (Nur Windows)

static void HOperatorSet.GetPrepInfoOcrClassSvm(HTuple OCRHandle, HTuple trainingFile, HTuple preprocessing, out HTuple informationCont, out HTuple cumInformationCont)

HTuple HOCRSvm.GetPrepInfoOcrClassSvm(HTuple trainingFile, string preprocessing, out HTuple cumInformationCont)

HTuple HOCRSvm.GetPrepInfoOcrClassSvm(string trainingFile, string preprocessing, out HTuple cumInformationCont)

Beschreibung

get_prep_info_ocr_class_svmget_prep_info_ocr_class_svmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvm berechnet den Informationsgehalt der mit der durch PreprocessingPreprocessingPreprocessingPreprocessingpreprocessing gegebenen Vorverarbeitung transformierten Komponenten der Trainingsvektoren. PreprocessingPreprocessingPreprocessingPreprocessingpreprocessing kann auf 'principal_components'"principal_components""principal_components""principal_components""principal_components" oder 'canonical_variates'"canonical_variates""canonical_variates""canonical_variates""canonical_variates" gesetzt werden. Der OCR-Klassifikator OCRHandleOCRHandleOCRHandleOCRHandleOCRHandle muss mit create_ocr_class_svmcreate_ocr_class_svmCreateOcrClassSvmCreateOcrClassSvmCreateOcrClassSvm erzeugt worden sein. Die zugrundeliegenden Vorverarbeitungen sind bei create_class_svmcreate_class_svmCreateClassSvmCreateClassSvmCreateClassSvm beschrieben. Der Informationsgehalt wird aus die Variation der transformierten Komponenten der Trainingsvektoren berechnet, d.h. er wird rein aufgrund der Trainingsdaten unabhängig von einer Fehlerrate bei einer Klassifikation der Trainingsdaten berechnet. Der Informationsgehalt wird für alle relevanten Komponenten der transformierten Merkmalsvektoren (NumFeatures für 'principal_components'"principal_components""principal_components""principal_components""principal_components" und min(NumClasses - 1, NumFeatures) für 'canonical_variates'"canonical_variates""canonical_variates""canonical_variates""canonical_variates", siehe create_class_svmcreate_class_svmCreateClassSvmCreateClassSvmCreateClassSvm) in InformationContInformationContInformationContInformationContinformationCont zurückgegeben. Der Informationsgehalt wird als eine Zahl zwischen 0 und 1 dargestellt. Ein prozentualer Informationsgehalt kann leicht durch Multiplikation mit 100 berechnet werden. Der kumulierte Informationsgehalt der ersten n Komponenten wird in der n-ten Komponente von CumInformationContCumInformationContCumInformationContCumInformationContcumInformationCont zurückgegeben, d.h. CumInformationContCumInformationContCumInformationContCumInformationContcumInformationCont enthält die Summen der ersten n Elemente von InformationContInformationContInformationContInformationContinformationCont. Um get_prep_info_ocr_class_svmget_prep_info_ocr_class_svmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvm verwenden zu können, müssen Trainingsmuster in den durch TrainingFileTrainingFileTrainingFileTrainingFiletrainingFile angegebenen Trainingsdateien abgespeichert werden (siehe write_ocr_trainfwrite_ocr_trainfWriteOcrTrainfWriteOcrTrainfWriteOcrTrainf).

InformationContInformationContInformationContInformationContinformationCont und CumInformationContCumInformationContCumInformationContCumInformationContcumInformationCont können dazu verwendet werden, um zu entscheiden, wieviele Komponenten der transformierten Merkmalsvektoren relevante Information enthalten. Ein oft verwendetes Kriterium ist z.B. zu verlangen, dass die transformierten Daten x% (z.B. 90%) der Daten enthalten sollten. Dies kann leicht anhand des ersten Wertes von CumInformationContCumInformationContCumInformationContCumInformationContcumInformationCont, der über x% liegt, bestimmt werden. Der so erhaltene Wert kann bei einem neuerlichen Aufruf von create_ocr_class_svmcreate_ocr_class_svmCreateOcrClassSvmCreateOcrClassSvmCreateOcrClassSvm als NumComponents verwendet werden. Da zum Aufruf von get_prep_info_ocr_class_svmget_prep_info_ocr_class_svmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvm schon ein Klassifikator mit create_ocr_class_svmcreate_ocr_class_svmCreateOcrClassSvmCreateOcrClassSvmCreateOcrClassSvm erzeugt werden muss, also auch ein initialer Wert von NumComponents bei create_ocr_class_svmcreate_ocr_class_svmCreateOcrClassSvmCreateOcrClassSvmCreateOcrClassSvm angegeben werden muss, aber bei Verwendung von get_prep_info_ocr_class_svmget_prep_info_ocr_class_svmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvm typischerweise noch nicht bekannt ist, wieviele Komponenten relevant sind, empfiehlt sich folgendes zweistufiges Vorgehen, um NumComponents zu bestimmen: In einem ersten Schritt wird ein Klassifikator mit der maximalen Anzahl von NumComponents (NumFeatures für 'principal_components'"principal_components""principal_components""principal_components""principal_components" und min(NumClasses - 1, NumFeatures) für 'canonical_variates'"canonical_variates""canonical_variates""canonical_variates""canonical_variates") erzeugt. Dann werden die Trainingsmuster mit write_ocr_trainfwrite_ocr_trainfWriteOcrTrainfWriteOcrTrainfWriteOcrTrainf in einer Datei gespeichert. Anschließend wird mit get_prep_info_ocr_class_svmget_prep_info_ocr_class_svmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvm der Informationsgehalt der Komponenten und somit NumComponents bestimmt. Danach wird ein neuer Klassifikator mit der gewünschten Anzahl Komponenten erzeugt und der Klassifikator mit trainf_ocr_class_svmtrainf_ocr_class_svmTrainfOcrClassSvmTrainfOcrClassSvmTrainfOcrClassSvm trainiert.

Ausführungsinformationen

Parameter

OCRHandleOCRHandleOCRHandleOCRHandleOCRHandle (input_control)  ocr_svm HOCRSvm, HTupleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Handle des OCR-Klassifikators.

TrainingFileTrainingFileTrainingFileTrainingFiletrainingFile (input_control)  filename.read(-array) HTupleHTupleHtuple (string) (string) (HString) (char*)

Name(n) der Trainingsdatei(en).

Defaultwert: 'ocr.trf' "ocr.trf" "ocr.trf" "ocr.trf" "ocr.trf"

Dateiendung: .trf, .otr

PreprocessingPreprocessingPreprocessingPreprocessingpreprocessing (input_control)  string HTupleHTupleHtuple (string) (string) (HString) (char*)

Art der Vorverarbeitung (Transformation) der Merkmalsvektoren.

Defaultwert: 'principal_components' "principal_components" "principal_components" "principal_components" "principal_components"

Werteliste: 'canonical_variates'"canonical_variates""canonical_variates""canonical_variates""canonical_variates", 'principal_components'"principal_components""principal_components""principal_components""principal_components"

InformationContInformationContInformationContInformationContinformationCont (output_control)  real-array HTupleHTupleHtuple (real) (double) (double) (double)

Relativer Informationsgehalt der transformierten Merkmalsvektoren.

CumInformationContCumInformationContCumInformationContCumInformationContcumInformationCont (output_control)  real-array HTupleHTupleHtuple (real) (double) (double) (double)

Kumulierter Informationsgehalt der transformierten Merkmalsvektoren.

Beispiel (HDevelop)

* Create the initial OCR classifier.
read_ocr_trainf_names ('ocr.trf', CharacterNames, CharacterCount)
create_ocr_class_svm (8, 10, 'constant', 'default', CharacterNames, \
                      'rbf', 0.01, 0.01, 'one-versus-one', \
                      'principal_components', 81, OCRHandle)
* Get the information content of the transformed feature vectors.
get_prep_info_ocr_class_svm (OCRHandle, 'ocr.trf', 'principal_components', \
                             InformationCont, CumInformationCont)
* Determine the number of transformed components.
* NumComp = [...]
* Create the final OCR classifier.
create_ocr_class_svm (8, 10, 'constant', 'default', CharacterNames, \
                      'rbf', 0.01, 0.01,'one-versus-one', \
                      'principal_components', NumComp, OCRHandle)
* Train the final classifier.
trainf_ocr_class_svm (OCRHandle, 'ocr.trf', 0.001, 'default')
write_ocr_class_svm (OCRHandle, 'ocr.osc')

Ergebnis

Sind die Parameterwerte korrekt, dann liefert get_prep_info_ocr_class_svmget_prep_info_ocr_class_svmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvm den Wert 2 (H_MSG_TRUE). Gegebenenfalls wird eine Fehlerbehandlung durchgeführt.

Falls get_prep_info_ocr_class_svmget_prep_info_ocr_class_svmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvmGetPrepInfoOcrClassSvm den Fehler 9211 (Matrix ist nicht positiv definit) bei PreprocessingPreprocessingPreprocessingPreprocessingpreprocessing = 'canonical_variates'"canonical_variates""canonical_variates""canonical_variates""canonical_variates" zurückliefert, bedeutet dies typischerweise, dass für die verschiedenen Klassen zu wenige Trainingsmuster gespeichert worden sind.

Vorgänger

create_ocr_class_svmcreate_ocr_class_svmCreateOcrClassSvmCreateOcrClassSvmCreateOcrClassSvm, write_ocr_trainfwrite_ocr_trainfWriteOcrTrainfWriteOcrTrainfWriteOcrTrainf, append_ocr_trainfappend_ocr_trainfAppendOcrTrainfAppendOcrTrainfAppendOcrTrainf, write_ocr_trainf_imagewrite_ocr_trainf_imageWriteOcrTrainfImageWriteOcrTrainfImageWriteOcrTrainfImage

Nachfolger

clear_ocr_class_svmclear_ocr_class_svmClearOcrClassSvmClearOcrClassSvmClearOcrClassSvm, create_ocr_class_svmcreate_ocr_class_svmCreateOcrClassSvmCreateOcrClassSvmCreateOcrClassSvm

Modul

OCR/OCV