MCPcopy Create free account
hub / github.com/creatale/node-dv / MakePrototype

Function MakePrototype

deps/tesseract/classify/cluster.cpp:975–1044  ·  view source on GitHub ↗

* This routine attempts to create a prototype from the * specified cluster that conforms to the distribution * specified in Config. If there are too few samples in the * cluster to perform a statistical analysis, then a prototype * is generated but labelled as insignificant. If the * dimensions of the cluster are not independent, no prototype * is generated and NULL is returned. If a prot

Source from the content-addressed store, hash-verified

973 * @note History: 6/19/89, DSJ, Created.
974 */
975PROTOTYPE *MakePrototype(CLUSTERER *Clusterer,
976 CLUSTERCONFIG *Config,
977 CLUSTER *Cluster) {
978 STATISTICS *Statistics;
979 PROTOTYPE *Proto;
980 BUCKETS *Buckets;
981
982 // filter out clusters which contain samples from the same character
983 if (MultipleCharSamples (Clusterer, Cluster, Config->MaxIllegal))
984 return NULL;
985
986 // compute the covariance matrix and ranges for the cluster
987 Statistics =
988 ComputeStatistics(Clusterer->SampleSize, Clusterer->ParamDesc, Cluster);
989
990 // check for degenerate clusters which need not be analyzed further
991 // note that the MinSamples test assumes that all clusters with multiple
992 // character samples have been removed (as above)
993 Proto = MakeDegenerateProto(
994 Clusterer->SampleSize, Cluster, Statistics, Config->ProtoStyle,
995 (inT32) (Config->MinSamples * Clusterer->NumChar));
996 if (Proto != NULL) {
997 FreeStatistics(Statistics);
998 return Proto;
999 }
1000 // check to ensure that all dimensions are independent
1001 if (!Independent(Clusterer->ParamDesc, Clusterer->SampleSize,
1002 Statistics->CoVariance, Config->Independence)) {
1003 FreeStatistics(Statistics);
1004 return NULL;
1005 }
1006
1007 if (HOTELLING && Config->ProtoStyle == elliptical) {
1008 Proto = TestEllipticalProto(Clusterer, Config, Cluster, Statistics);
1009 if (Proto != NULL) {
1010 FreeStatistics(Statistics);
1011 return Proto;
1012 }
1013 }
1014
1015 // create a histogram data structure used to evaluate distributions
1016 Buckets = GetBuckets(Clusterer, normal, Cluster->SampleCount,
1017 Config->Confidence);
1018
1019 // create a prototype based on the statistics and test it
1020 switch (Config->ProtoStyle) {
1021 case spherical:
1022 Proto = MakeSphericalProto(Clusterer, Cluster, Statistics, Buckets);
1023 break;
1024 case elliptical:
1025 Proto = MakeEllipticalProto(Clusterer, Cluster, Statistics, Buckets);
1026 break;
1027 case mixed:
1028 Proto = MakeMixedProto(Clusterer, Cluster, Statistics, Buckets,
1029 Config->Confidence);
1030 break;
1031 case automatic:
1032 Proto = MakeSphericalProto(Clusterer, Cluster, Statistics, Buckets);

Callers 1

ComputePrototypesFunction · 0.85

Calls 9

ComputeStatisticsFunction · 0.85
MakeDegenerateProtoFunction · 0.85
FreeStatisticsFunction · 0.85
IndependentFunction · 0.85
TestEllipticalProtoFunction · 0.85
GetBucketsFunction · 0.85
MakeSphericalProtoFunction · 0.85
MakeEllipticalProtoFunction · 0.85
MakeMixedProtoFunction · 0.85

Tested by

no test coverage detected