private static void LearnRotations(List<Patch> patches, Tree tree) { for (int iters = 0; iters < 2; iters++) { // Loop over the patches foreach (var p in patches) { int bestCount = 0; int bestAngle = 0; var oldnd = p.NodeIndex; var newnd = -1; // Loop over rotations for (int angle = 0; angle < 360; angle += 5) { p.Angle = angle; // Apply the tree to the patch var leaf = tree.Apply(p); // See if bigger, if so store best rotation if (leaf.Count > bestCount) { bestCount = leaf.Count; bestAngle = angle; newnd = leaf.Index; } } // Move to node for best rotation p.NodeIndex = newnd; p.Angle = bestAngle; tree.Nodes[oldnd].Count--; tree.Nodes[newnd].Count++; } } }
private static void LearnRotations(List <Patch> patches, Tree tree) { for (int iters = 0; iters < 2; iters++) { // Loop over the patches foreach (var p in patches) { int bestCount = 0; int bestAngle = 0; var oldnd = p.NodeIndex; var newnd = -1; // Loop over rotations for (int angle = 0; angle < 360; angle += 5) { p.Angle = angle; // Apply the tree to the patch var leaf = tree.Apply(p); // See if bigger, if so store best rotation if (leaf.Count > bestCount) { bestCount = leaf.Count; bestAngle = angle; newnd = leaf.Index; } } // Move to node for best rotation p.NodeIndex = newnd; p.Angle = bestAngle; tree.Nodes[oldnd].Count--; tree.Nodes[newnd].Count++; } } }
private static void LearnTranslations(List <Patch> patches, Tree tree) { int max = 16; int step = 2; // Loop over the patches foreach (var p in patches) { int bestCount = 0; int bestX = 0; int bestY = 0; var oldnd = p.NodeIndex; var newnd = -1; // Loop over rotations for (int y = -max; y <= max; y += step) { for (int x = -max; x <= max; x += step) { p.NudgeX = x; p.NudgeY = y; if ((x + p.Left < 0) || (x + p.Left + p.Width >= p.Image.Bitmap.PixelWidth)) { continue; } if ((y + p.Top < 0) || (y + p.Top + p.Height >= p.Image.Bitmap.PixelHeight)) { continue; } // Apply the tree to the patch var leaf = tree.Apply(p); // See if bigger, if so store best rotation if (leaf.Count > bestCount) { bestCount = leaf.Count; bestX = x; bestY = y; newnd = leaf.Index; } } } // Move to node for best rotation p.NodeIndex = newnd; p.NudgeX = bestX; p.NudgeY = bestY; tree.Nodes[oldnd].Count--; tree.Nodes[newnd].Count++; } }
private static void LearnTranslations(List<Patch> patches, Tree tree) { int max = 16; int step = 2; // Loop over the patches foreach (var p in patches) { int bestCount = 0; int bestX = 0; int bestY = 0; var oldnd = p.NodeIndex; var newnd = -1; // Loop over rotations for (int y = -max; y <= max; y += step) { for (int x = -max; x <= max; x += step) { p.NudgeX = x; p.NudgeY = y; if ((x + p.Left < 0) || (x + p.Left + p.Width >= p.Image.Bitmap.PixelWidth)) continue; if ((y + p.Top < 0) || (y + p.Top + p.Height >= p.Image.Bitmap.PixelHeight)) continue; // Apply the tree to the patch var leaf = tree.Apply(p); // See if bigger, if so store best rotation if (leaf.Count > bestCount) { bestCount = leaf.Count; bestX = x; bestY = y; newnd = leaf.Index; } } } // Move to node for best rotation p.NodeIndex = newnd; p.NudgeX = bestX; p.NudgeY = bestY; tree.Nodes[oldnd].Count--; tree.Nodes[newnd].Count++; } }