Пример #1
0
        /// <summary>
        /// Add the image created by substrokes into the current image, no normalize
        /// </summary>
        /// <param name="substrokes">Substrokes to add to current image</param>
        private void addDefinition(Substrokes substrokes)
        {
            DefinitionImage di = new DefinitionImage(m_width, m_height, substrokes);

            m_image.matrix.Add(di.m_image.matrix);
            m_polar.matrix.Add(di.m_polar.matrix);
            m_imageTransform.matrix.Add(di.m_imageTransform.matrix);
            m_polarTransform.matrix.Add(di.m_polarTransform.matrix);

            //for single images
            m_rotatedImages = di.m_rotatedImages;

            //This is used to specify that all of the following images should match the first images orientation.
            //This is particularly useful when creating the average image ;)!
            if (m_matches.Count == 0)
            {
                m_matches.Add(di);
            }

            if (true)
            {
                di.Main.writeToBitmap("main" + counter.ToString() + ".bmp");
                di.Polar.writeToBitmap("polar" + counter.ToString() + ".bmp");
            }
            ++counter;

            /* Do not normalize here.
             * We will do that after the whole list from addDefinition(List<>) has been added.
             */
        }
Пример #2
0
        /// <summary>
        /// Finds the amount to translate each column, and translates that amount.
        /// </summary>
        /// <param name="A">Image to match to</param>
        /// <param name="angle">The angle in radians that the image was translated</param>
        /// <param name="bestDist">The dist of the best match</param>
        public void translateToMatch(DefinitionImage A, out double angle, out double bestDist)
        {
            //Find the best amount to move cols
            int colsToTranslate;

            findBestTranslation(A, out colsToTranslate, out bestDist);

            translate(colsToTranslate);

            angle = colsToAngle(colsToTranslate);
        }
Пример #3
0
        private void addDefinition(Substrokes substrokes, DefinitionImage matchTo)
        {
            DefinitionImage di = new DefinitionImage(m_width, m_height, substrokes, matchTo);

            m_image.matrix.Add(di.m_image.matrix);
            m_polar.matrix.Add(di.m_polar.matrix);
            m_imageTransform.matrix.Add(di.m_imageTransform.matrix);
            m_polarTransform.matrix.Add(di.m_polarTransform.matrix);

            if (true)
            {
                di.Main.writeToBitmap("out" + counter.ToString() + ".bmp");
            }
            ++counter;
        }
Пример #4
0
        /// <summary>
        /// Finds the amount to move each column by translating all of the columns and finding the best one.
        /// </summary>
        /// <param name="A">Image to match to</param>
        /// <param name="cols">Number of columns to best translation</param>
        /// <param name="dist">Best distance</param>
        public void findBestTranslation(DefinitionImage A, out int cols, out double bestDist)
        {
            double dist;

            bestDist = double.PositiveInfinity;
            cols     = -1;

            Image translated = new Image(this);

            Metrics.ImageDistance id;

            //Go over the potential column translations
            int i, len = _width;

            for (i = 0; i < len; ++i)
            {
                //Store the translation in translated
                TranslateMatrix(i, ref matrix, ref translated.matrix);


                //dist = id.distance(Metrics.ImageDistance.DIRECTEDMODIFIEDHAUSDORFF_AB);
                //dist = id.distance(Metrics.ImageDistance.TANIMOTO) + id.distance(Metrics.ImageDistance.YULE);
                //dist = id.distance(Metrics.ImageDistance.VERTICAL);
                //dist = id.distance(Metrics.ImageDistance.DIRECTEDHAUSDORFF_AB);
                //dist = id.distance(Metrics.ImageDistance.OVERLAPPING_AB);
                //dist = id.distance(Metrics.ImageDistance.HORIZONTAL);
                //id = new Metrics.ImageDistance(translated, A.Polar);
                //dist = id.distance(Metrics.ImageDistance.TANIMOTO) * id.distance(Metrics.ImageDistance.YULE);
                id   = new Metrics.ImageDistance(translated, A.PolarTransform);
                dist = id.distance(Metrics.ImageDistance.DIRECTEDMODIFIEDHAUSDORFF_AB);
                if (dist < bestDist)
                {
                    bestDist = dist;
                    cols     = i;
                }
            }
        }
Пример #5
0
 public DefinitionImage(int width, int height, Substrokes substrokes, DefinitionImage matchTo)
     : this(width, height, substrokes, new List <DefinitionImage>(new DefinitionImage[] { matchTo }))
 {
 }
Пример #6
0
 public static void AddMatch(DefinitionImage A)
 {
     m_matches.Add(A);
 }