Пример #1
0
        public double ModelError(Matrix <double> model, AffineRegionsPair pair)
        {
            AffineRegion baseRegion        = pair.SecondImageRegion;
            Point        transformedRegion = Transform(pair.FirstImageRegion, model);

            return(baseRegion.CalculateDistance(transformedRegion));
        }
Пример #2
0
        protected override Point Transform(AffineRegion region, Matrix <double> model)
        {
            int x = region.X;
            int y = region.Y;

            Vector <double> baseVector = DenseVector.OfArray(new double[] {
                x,
                y,
                1
            });

            Vector <double> transformedVector = model * baseVector;

            int u = (int)transformedVector[0];
            int v = (int)transformedVector[1];

            return(new Point(u, v));
        }
Пример #3
0
        private List <AffineRegionsPair> GetPairsOfOneSide(List <AffineRegion> mainRegions, List <AffineRegion> compareToRegions)
        {
            List <AffineRegionsPair> pairsOfMainSide = new List <AffineRegionsPair>();

            foreach (AffineRegion m in mainRegions)
            {
                double       bestSimilarity    = -1; // by definition, cosine similarity varies between -1 and 1
                AffineRegion mostSimilarRegion = null;
                foreach (AffineRegion c in compareToRegions)
                {
                    double similarity = m.Params.GetCosineSimilarity(c.Params);
                    if (similarity > bestSimilarity /*&& similarity > 0.95*/)   // heuristic
                    {
                        bestSimilarity    = similarity;
                        mostSimilarRegion = c;
                    }
                }
                pairsOfMainSide.Add(new AffineRegionsPair(m, mostSimilarRegion, bestSimilarity));
            }

            return(pairsOfMainSide);
        }
Пример #4
0
 public AffineRegionsPair(AffineRegion firstImageRegion, AffineRegion secondImageRegion, double similarity)
 {
     FirstImageRegion  = firstImageRegion;
     SecondImageRegion = secondImageRegion;
     Similarity        = similarity;
 }
Пример #5
0
 protected abstract Point Transform(AffineRegion region, Matrix <double> model);