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

Function ComputePrototypes

deps/tesseract/classify/cluster.cpp:930–956  ·  view source on GitHub ↗

* This routine decides which clusters in the cluster tree * should be represented by prototypes, forms a list of these * prototypes, and places the list in the Clusterer data * structure. * @param Clusterer data structure holding cluster tree * @param Config parameters used to control prototype generation * @return None * @note Exceptions: None * @note History: 5/30/89, DSJ, Created.

Source from the content-addressed store, hash-verified

928 * @note History: 5/30/89, DSJ, Created.
929 */
930void ComputePrototypes(CLUSTERER *Clusterer, CLUSTERCONFIG *Config) {
931 LIST ClusterStack = NIL_LIST;
932 CLUSTER *Cluster;
933 PROTOTYPE *Prototype;
934
935 // use a stack to keep track of clusters waiting to be processed
936 // initially the only cluster on the stack is the root cluster
937 if (Clusterer->Root != NULL)
938 ClusterStack = push (NIL_LIST, Clusterer->Root);
939
940 // loop until we have analyzed all clusters which are potential prototypes
941 while (ClusterStack != NIL_LIST) {
942 // remove the next cluster to be analyzed from the stack
943 // try to make a prototype from the cluster
944 // if successful, put it on the proto list, else split the cluster
945 Cluster = (CLUSTER *) first_node (ClusterStack);
946 ClusterStack = pop (ClusterStack);
947 Prototype = MakePrototype(Clusterer, Config, Cluster);
948 if (Prototype != NULL) {
949 Clusterer->ProtoList = push (Clusterer->ProtoList, Prototype);
950 }
951 else {
952 ClusterStack = push (ClusterStack, Cluster->Right);
953 ClusterStack = push (ClusterStack, Cluster->Left);
954 }
955 }
956} // ComputePrototypes
957
958/**
959 * This routine attempts to create a prototype from the

Callers 1

ClusterSamplesFunction · 0.85

Calls 3

pushFunction · 0.85
popFunction · 0.85
MakePrototypeFunction · 0.85

Tested by

no test coverage detected