public void addPoints(ref List <ExpressPoint> list, ref float treshold, ref float neighborLevel, ref float increaseResolutionThreshold, ref float minDistance) { float childVariance, tmp; float parentVariance = this.variance(out tmp); //TODO make resolution easier adjustable if ((parentVariance > increaseResolutionThreshold) && (Math.Abs(x1 - x2) > MIN_DISTANCE))//(1.0f - parentVariance))) { foreach (Rect r in childs) { if (r.childs.Count == 0) { // Console.WriteLine(Math.Abs(r.x1 - r.x2) / 2.0); r.createTree(Math.Abs(r.x1 - r.x2) / 2.0);//TODO Calculate Abs only once } } } foreach (Rect r in childs) { childVariance = r.variance(out tmp); if (childVariance >= treshold) //greater or greater and equal? { r.addPoints(ref list, ref treshold, ref neighborLevel, ref increaseResolutionThreshold, ref minDistance); } else { //TODO check if this is doing the right thing bool add = false; float maxValue = 0; for (int b = 0; b < 2; b++) { // Console.WriteLine(b); if (r.neighborDifference(b, ref maxValue) > neighborLevel) { add = true; break; } } if (add) { if (Math.Abs(r.activationLevel) > CONNECTION_TRESHOLD)//&& ((dist/2.5f) < Math.Abs(r.thr)))//&& (r.y2>=r.y1))//(dist / 2.0f + 0.5)) { ExpressPoint p = new ExpressPoint(r.fixedx, r.fixedy, r.x1, r.x2, r.y1, r.y2, 1.0f, r.activationLevel); list.Add(p); } } } } }
//Add the points (i.e. connections) that are discovered by the algorithm. This function is recursivly applied until the variance is not //higher than the given threhold public void addPoints(ref List <ExpressPoint> list, ref float treshold, ref float bandLevel, ref float divisionThreshold, ref int maximumResolution) { float childVariance, tmp; float parentVariance = this.variance(out tmp); //TODO include maximum resolution if ((parentVariance > divisionThreshold))//&& (currentResolution < (maximumResolution*maximumResolution) ))//(1.0f - parentVariance))) { foreach (Rect r in childs) { if (r.childs.Count == 0) { // Console.WriteLine(Math.Abs(r.x1 - r.x2) / 2.0); r.createTree(2);//divide once } } } foreach (Rect r in childs) { childVariance = r.variance(out tmp); if (childVariance >= treshold) //greater or greater and equal? { r.addPoints(ref list, ref treshold, ref bandLevel, ref divisionThreshold, ref maximumResolution); } else { bool add = false; float maxValue = 0; for (int b = 0; b < 2; b++) { // Console.WriteLine(b); if (r.neighborDifference(b, ref maxValue) > bandLevel) { add = true; break; } } if (add) { ExpressPoint p = new ExpressPoint(r.fixedx, r.fixedy, r.x1, r.x2, r.y1, r.y2, 1.0f, r.activationLevel); list.Add(p); } } } }