public void TestVaryingSizesComparison() { testName = "VaryingSizeComparison"; Random r = new Random(); int smallW = 5, smallH = 7; bool[][] smallMatrix = new bool[smallW][]; for (int x = 0; x < smallW; ++x) { smallMatrix[x] = new bool[smallH]; for (int y = 0; y < smallH; ++y) { smallMatrix[x][y] = r.Next(2) == 1 ? true : false; } } ImageMatrix main = new ImageMatrix(smallMatrix); ImageMatrix second = MatrixTools.Scale(main, 10, 6); var r2 = MatrixTools.EqualPixelRatioVaryingSize(main, second); TEST(r2 >= 0.99 && r2 <= 1.0, $"Comparison varying sizes is below 0.99, received ratio: {r2}"); }
private char MatchLetter(ImageMatrix letter, IEnumerable <ImageMatrix> matchers) { char theOne = '_'; float theRatio = 0; foreach (var m in matchers) { if (EgligableForRecognition(letter, m)) { float ratio = MatrixTools.EqualPixelRatioVaryingSize(m, letter); if (ratio > theRatio) { theRatio = ratio; theOne = m.Character; } } } if (theRatio == 0) { return(',');//CommaOrDot(letter); } return(theOne); }