private void DisplayImageAsAsciiInConsole(CharacterImage image) { CharacterImage.NormalizeTo32x32Type normalizeTo32x32OpType = CharacterImage.NormalizeTo32x32Type.UnbiasedRatio; if (!image.IsNormalizedTo32x32()) { image.NormalizeTo32x32(normalizeTo32x32OpType); } if (!image.IsMadeOnlyBlackAndWhite()) { image.MakeOnlyBlackAndWhite(); } String lastImageLinearizedAsString = image.LinearizeImageToString(normalizeTo32x32OpType); int cnt = 0; for (int i = 0; i < 32; i++) { for (int j = 0; j < 32; j++) { char ch = '0'; if (lastImageLinearizedAsString[cnt] == '0') { ch = '0'; } else { ch = ' '; } cnt++; Console.Write(ch); } Console.WriteLine(); } }
private void drawPanel_MouseUp(object sender, MouseEventArgs e) { if (m_canDraw == false) { return; } m_canDraw = false; m_connectedComponents = connectedComponentsTool.InspectConnectedComponents(m_auxiliaryBitmap); // TODO: sort the connected components according to their position in the panel. this is already happening in Word class. ConnectedComponent lastConnectedComponent = m_connectedComponents.Last(); CharacterImage lastImage = new CharacterImage(lastConnectedComponent); DisplayImageAsAsciiInConsole(lastImage); // WARNING!! CharacterImage.NormalizeTo32x32Type normalizeTo32x32OpType = CharacterImage.NormalizeTo32x32Type.UnbiasedRatio; //CharacterImage.NormalizeTo32x32Type normalizeTo32x32OpType = CharacterImage.NormalizeTo32x32Type.BiasedRatio; if (!lastImage.IsNormalizedTo32x32()) { lastImage.NormalizeTo32x32(normalizeTo32x32OpType); } if (!lastImage.IsMadeOnlyBlackAndWhite()) { lastImage.MakeOnlyBlackAndWhite(); } lastImage.ThickenBlackPixels(); String lastImageLinearizedAsString = lastImage.LinearizeImageToString(normalizeTo32x32OpType); ConnectionManager.SendLinearizedImageForClassification(lastImageLinearizedAsString, connectedComponentsTool.GetLatestAdjustmentId()); }