当前位置: 首页>>代码示例>>C#>>正文


C# Tile.GetMatches方法代码示例

本文整理汇总了C#中Tile.GetMatches方法的典型用法代码示例。如果您正苦于以下问题:C# Tile.GetMatches方法的具体用法?C# Tile.GetMatches怎么用?C# Tile.GetMatches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tile的用法示例。


在下文中一共展示了Tile.GetMatches方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CompareSimilarPatterns

        public void CompareSimilarPatterns()
        {
            // Setup
            int bitsPerColour = 8;
            int tileSize = 16;
            int offsetX = 0;
            int offsetY = 0;

            //Bitmap croppedImage = Program.LoadImage(@"C:\Users\nicB\Documents\tileTest.png");
            Program.LoadImage(@"C:\Users\nicB\Documents\tileTest.png", tileSize, offsetX, offsetY);

            //int x = 0;
            //int y = 0;
            int index = 0;

            //Bitmap image1 = Program.GetTileImage(x, y, TileSize);
            Bitmap image1 = Program.GetTileImage(index);
            Tile tile1 = new Tile(image1, bitsPerColour, tileSize, index);
            Console.WriteLine("Tile 1: " + tile1.ToString());

            //x = 16;
            index = 1;
            //Bitmap image2 = Program.GetTileImage(x, y, TileSize);
            Bitmap image2 = Program.GetTileImage(index);
            Tile tile2 = new Tile(image2, bitsPerColour, tileSize, 1);
            Console.WriteLine("Tile 2: " + tile2.ToString());

            // Execution
            Tuple<float, float> results = tile1.GetMatches(tile2);
            float patternMatch = results.Item1;
            float colourMatch = results.Item2;

            bool identical = tile1.IdenticalTo(tile2);

            // Assertion
            float expectedPatternMatch = 223 / 255f;
            Assert.IsTrue(patternMatch == expectedPatternMatch, string.Format("Expected {0}, Actual {1}", expectedPatternMatch, patternMatch));

            Assert.IsFalse(identical);
        }
开发者ID:Blkx-Darkreaper,项目名称:Workspace,代码行数:40,代码来源:UnitTests.cs

示例2: FindMatchingGroupWithResults

        private static TileGroupMatchResults FindMatchingGroupWithResults(Tile tileToCompare, float patternThreshold, float colourThreshold)
        {
            foreach (TileGroup group in allSortedTiles)
            {
                //int masterIndex = group.MasterIndex;
                //Tile Master = allSubImageTiles[MasterIndex];
                //Tile master = allSubImageTiles.ElementAt(masterIndex);
                Tile master = group.Master;
                Tuple<float, float> results = tileToCompare.GetMatches(master);
                float patternMatch = results.Item1;
                float colourMatch = results.Item2;

                bool areSimilar = Tile.SimilarTo(patternMatch, patternThreshold);
                if (areSimilar == false)
                {
                    continue;
                }

                return new TileGroupMatchResults(group, patternMatch, colourMatch);
            }

            return new TileGroupMatchResults();
        }
开发者ID:Blkx-Darkreaper,项目名称:Workspace,代码行数:23,代码来源:Program.cs

示例3: CompareSimilarToMaster

        public void CompareSimilarToMaster()
        {
            // Setup
            int bitsPerColour = 8;
            int accuracy = 2;
            int tileCount = 32;
            int tileSize = 16;
            int offsetX = 0;
            int offsetY = 0;

            //Bitmap canvas = Program.LoadImage(@"C:\Users\nicB\Documents\tileTest.png");
            Program.LoadImage(@"C:\Users\nicB\Documents\tileTest.png", tileSize, offsetX, offsetY);

            //int x = 0;
            //int y = 0;
            int index = 0;

            //Bitmap image1 = Program.GetTileImage(x, y, TileSize);
            Bitmap image1 = Program.GetTileImage(index);
            Tile master = new Tile(image1, bitsPerColour, tileSize, index);
            //Console.WriteLine("Tile 1: " + tileToDraw.ToString());

            Tile identicalTile = new Tile(image1, bitsPerColour, tileSize, index);

            //x = 16;
            index = 1;
            //Bitmap image2 = Program.GetTileImage(x, y, TileSize);
            Bitmap image2 = Program.GetTileImage(index);
            Tile similarTile = new Tile(image2, bitsPerColour, tileSize, index);
            //Console.WriteLine("Tile 2: " + similarTile.ToString());

            //x = 32;
            index = 2;
            //Bitmap image3 = Program.GetTileImage(x, y, TileSize);
            Bitmap image3 = Program.GetTileImage(index);
            Tile otherSimilarTile = new Tile(image3, bitsPerColour, tileSize, index);
            //Console.WriteLine("Tile 3: " + otherSimilarTile.ToString());

            Tuple<float, float> identicalResults = master.GetMatches(identicalTile);
            float patternMatch = identicalResults.Item1;
            float colourMatch = identicalResults.Item2;
            int identicalHashCode = Tile.GetHashcode(accuracy, patternMatch, colourMatch, tileCount);

            // Execution
            Tuple<float, float> similarResults = master.GetMatches(similarTile);
            patternMatch = similarResults.Item1;
            colourMatch = similarResults.Item2;
            int similarHashCode = Tile.GetHashcode(accuracy, patternMatch, colourMatch, tileCount);

            Tuple<float, float> otherSimilarResults = master.GetMatches(otherSimilarTile);
            patternMatch = similarResults.Item1;
            colourMatch = similarResults.Item2;
            int otherSimilarHashCode = Tile.GetHashcode(accuracy, patternMatch, colourMatch, tileCount);

            // Assertion
            Assert.IsTrue(identicalHashCode == 0, string.Format("Expected 0, Actual {0}", identicalHashCode));

            Assert.IsTrue(similarHashCode == otherSimilarHashCode, string.Format("Expected true, Actual {0} == {1}", similarHashCode, otherSimilarHashCode));
        }
开发者ID:Blkx-Darkreaper,项目名称:Workspace,代码行数:59,代码来源:UnitTests.cs


注:本文中的Tile.GetMatches方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。