Example #1
0
        public MarkovNetwork(Image <Rgb, byte> left, Image <Rgb, byte> right)
        {
            RightMap = new double[right.Height, right.Width][];
            for (int y = 0; y < right.Height; y++)
            {
                for (int x = 0; x < right.Width; x++)
                {
                    var pixel = right[y, x];
                    RightMap[y, x] = new[] { pixel.Red, pixel.Green, pixel.Blue };
                }
            }

            Net = new MarkovNode[left.Height, left.Width];

            for (int y = 0; y < left.Height; y++)
            {
                for (int x = 0; x < left.Width; x++)
                {
                    var pixel = left[y, x];
                    Net[y, x] = new MarkovNode(x, y, new[] { pixel.Red, pixel.Green, pixel.Blue }, RightMap);
                    Nodes.Add(Net[y, x]);
                }
            }

            SetEdges();
        }
Example #2
0
        private double GetEdgeMetric(MarkovNode node1, int dx1, MarkovNode node2, int dx2)
        {
            var dist = SqrDist(node1, node2);

            return(Math.Abs(dx1 - dx2) > MaxDelta
                                ? nearDxGaussians[dist].GetDensity(MaxDelta)
                                : nearDxGaussians[dist].GetDensity(dx1 - dx2));
        }
Example #3
0
 private static int SqrDist(MarkovNode node1, MarkovNode node2)
 {
     return((node1.Y - node2.Y) * (node1.Y - node2.Y) + (node1.X - node2.X) * (node1.X - node2.X));
 }
Example #4
0
 private int SqrDist(MarkovNode node)
 {
     return(SqrDist(node, this));
 }
Example #5
0
        public Dictionary <int, double> GenerateProbabilities(IEnumerable <int> variants, MarkovNode node)
        {
            if (vars == null)
            {
                vars = new Dictionary <int, double>();
            }
            vars.Clear();

            foreach (var variant in variants)
            {
                vars[variant] = GetEdgeMetric(this, Dx, node, variant);
            }
            return(vars);
        }