Ejemplo n.º 1
0
        public static VectorRgb ProbabilityFinaly(int h, int w, List <List <VectorRgb> > first, List <List <VectorRgb> > second, List <List <Shift> > shift)
        {
            List <List <VectorRgb> > probMatrix = ProbabilityByShift(h, w, first, second, shift);

            Debug.PrintMatrix(probMatrix, @"C:\Users\romashchenko\Dropbox\univer_diplom\debug\probMatrix");
            VectorRgb mult = new VectorRgb(0, 0, 0);

            for (int i = 1; i < h - 1; i++)
            {
                for (int j = 1; j < w - 1; j++)
                {
                    var temp = probMatrix[i][j];
                    foreach (var neighbor in new[] { shift[i - 1][j], shift[i + 1][j], shift[i][j - 1], shift[i][j + 1] })
                    {
                        temp *= new VectorRgb(ProbabilityByNeighbors(shift[i][j], neighbor), ProbabilityByNeighbors(shift[i][j], neighbor), ProbabilityByNeighbors(shift[i][j], neighbor));
                    }
                    mult += temp;
                }
            }
            return(mult);
        }
Ejemplo n.º 2
0
 public static double ExecuteDistance(VectorRgb s, VectorRgb p)
 {
     return(Math.Sqrt(Math.Pow(s.R - p.R, 2) + Math.Pow(s.G - p.G, 2) + Math.Pow(s.B - p.B, 2)) != 0 ?
            Math.Sqrt(Math.Pow(s.R - p.R, 2) + Math.Pow(s.G - p.G, 2) + Math.Pow(s.B - p.B, 2)) : 0.01);
 }