Exemplo n.º 1
0
 public double calculateDifferenceOnlyByDistance(Feature anotherFeature)
 {
     double diff = 0;
     diff = diff + (Math.Abs(anotherFeature.pixel_to_next_left - this.pixel_to_next_left));
     diff = diff + (Math.Abs(anotherFeature.pixel_to_next_right - this.pixel_to_next_right));
     return diff;
 }
Exemplo n.º 2
0
 public double calculateDifferenceWithAllAngles(Feature anotherFeature)
 {
     double diff = (anotherFeature.angle_at_pixel - this.angle_at_pixel) * (anotherFeature.angle_at_pixel - this.angle_at_pixel) * (anotherFeature.angle_at_pixel - this.angle_at_pixel) * (anotherFeature.angle_at_pixel - this.angle_at_pixel);
     diff = diff + (Math.Abs(anotherFeature.angle_left - this.angle_left));
     diff = diff + (Math.Abs(anotherFeature.angle_right - this.angle_right));
     return diff;
 }
Exemplo n.º 3
0
        public double calculateDifferenceWithDistance(Feature anotherFeature)
        {
            double diff = (anotherFeature.angle_at_pixel - this.angle_at_pixel) * (anotherFeature.angle_at_pixel - this.angle_at_pixel);
            diff = diff + (Math.Abs(anotherFeature.pixel_to_next_left - this.pixel_to_next_left));
            diff = diff + (Math.Abs(anotherFeature.pixel_to_next_right - this.pixel_to_next_right));

            return diff;
        }
        public Transformation calculateTransformation(List<Contour<Point>> contours_image1, List<Contour<Point>> contours_image2)
        {
            List<Feature> image1_features = new List<Feature>();
            List<Feature> image2_features = new List<Feature>();

            //Get the points of the FIRST (=0) contour
            Point[] points1 = contours_image1[0].ToArray();

            //Calculate the angle at every pixel for picture 1
            for (int i = 0; i < points1.Length; i++)
            {
                AngleCalculator angleCalculator = new AngleCalculator();
                double angle = angleCalculator.calculateAngle (points1, i);
                Feature f = new Feature();
                f.point = points1[i];
                f.angle_at_pixel = angle;
                image1_features.Add(f);
            }

            //Get the points of the FIRST (=0) contour
            Point[] points2 = contours_image2[0].ToArray();

            //Calculate the angle at every pixel for picture 2
            for (int i = 0; i < points2.Length; i++)
            {
                AngleCalculator angleCalculator = new AngleCalculator();
                double angle = angleCalculator.calculateAngle(points2, i);
                Feature f = new Feature();
                f.point = points2[i];
                f.angle_at_pixel = angle;
                image2_features.Add(f);
            }

            GraphAnalyzer graphanalyzer = new GraphAnalyzer();

            //Normalize the shorter contour to longer one
            List<Feature> image1_features_normalized;
            List<Feature> image2_features_normalized;
            if (image1_features.Count < image2_features.Count)
            {
                image1_features_normalized = graphanalyzer.normalize(image2_features, image1_features);
                image2_features_normalized = image2_features;
            }
            else
            {
                image2_features_normalized = graphanalyzer.normalize(image1_features, image2_features);
                image1_features_normalized = image1_features;
            }

            //Moves the contour(graph) of image1 to best matching
            image1_features_normalized = graphanalyzer.matchGraphs(image1_features_normalized, image2_features_normalized);

            //Get the best Features by using extrema [0] image1 --> [1] image2, ....
            List<Feature> bestFeatures = graphanalyzer.findBestFeaturesWithExtrema(image1_features_normalized, image2_features_normalized);
            bestFeatureStorage1.Add(bestFeatures[0]);
            bestFeatureStorage1.Add(bestFeatures[2]);
            bestFeatureStorage2.Add(bestFeatures[1]);
            bestFeatureStorage2.Add(bestFeatures[3]);

            //Calculating the transformation for the best features
            Transformation transformation = calculateTransformationValues(bestFeatures);

            //Exporting the graph
            Exporter exporter = new Exporter();
            exporter.exportFeatures(image1_features_normalized, image2_features_normalized);

            return transformation;
        }
Exemplo n.º 5
0
 public double calculateDifferenceOnlyByAngle(Feature anotherFeature)
 {
     double diff = (anotherFeature.angle_at_pixel - this.angle_at_pixel) * (anotherFeature.angle_at_pixel - this.angle_at_pixel);
     return diff;
 }