本文整理汇总了C#中Nikse.SubtitleEdit.Logic.NikseBitmap.MakeOneColor方法的典型用法代码示例。如果您正苦于以下问题:C# NikseBitmap.MakeOneColor方法的具体用法?C# NikseBitmap.MakeOneColor怎么用?C# NikseBitmap.MakeOneColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nikse.SubtitleEdit.Logic.NikseBitmap
的用法示例。
在下文中一共展示了NikseBitmap.MakeOneColor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OcrViaTesseract
//.........这里部分代码省略.........
newText = newText.TrimEnd() + "...";
else if (textWithOutFixes.Length > 0 && textWithOutFixes.EndsWith(".") && !newText.EndsWith(".") && !newText.EndsWith(",") && !newText.EndsWith("!") &&
!newText.EndsWith("?") && !newText.EndsWith("</i>"))
newText = newText.TrimEnd() + ".";
else if (textWithOutFixes.Length > 0 && textWithOutFixes.EndsWith("?") && !newText.EndsWith(".") && !newText.EndsWith(",") && !newText.EndsWith("!") &&
!newText.EndsWith("?") && !newText.EndsWith("</i>"))
newText = newText.TrimEnd() + "?";
textWithOutFixes = newUnfixedText;
line = FixItalics(newText);
}
else if (correctWords > oldCorrectWords + 1 || (correctWords > oldCorrectWords && !textWithOutFixes.Contains(" ")))
{
wordsNotFound = newWordsNotFound;
textWithOutFixes = newUnfixedText;
line = newText;
}
else
{
_ocrFixEngine.UnknownWordsFound.Clear();
_ocrFixEngine.UnknownWordsFound.AddRange(oldUnkownWords);
}
}
if (wordsNotFound > 0 || correctWords == 0 || textWithOutFixes != null && textWithOutFixes.ToString().Replace("~", string.Empty).Trim().Length < 2)
{
if (_bluRaySubtitles != null && !line.Contains("<i>"))
{
_ocrFixEngine.AutoGuessesUsed.Clear();
_ocrFixEngine.UnknownWordsFound.Clear();
// which is best - normal image or one color image?
var nbmp = new NikseBitmap(bitmap);
nbmp.MakeOneColor(Color.White);
Bitmap oneColorBitmap = nbmp.GetBitmap();
string oneColorText = Tesseract3DoOcrViaExe(oneColorBitmap, _languageId, "-psm 6"); // 6 = Assume a single uniform block of text.
oneColorBitmap.Dispose();
nbmp = null;
if (oneColorText.Length > 1 &&
!oneColorText.Contains("CD") &&
(!oneColorText.Contains("0") || line.Contains("0")) &&
(!oneColorText.Contains("2") || line.Contains("2")) &&
(!oneColorText.Contains("3") || line.Contains("4")) &&
(!oneColorText.Contains("5") || line.Contains("5")) &&
(!oneColorText.Contains("9") || line.Contains("9")) &&
(!oneColorText.Contains("•") || line.Contains("•")) &&
(!oneColorText.Contains(")") || line.Contains(")")) &&
Utilities.CountTagInText(oneColorText, "(") < 2 && Utilities.CountTagInText(oneColorText, ")") < 2 &&
Utilities.CountTagInText(oneColorText, Environment.NewLine) < 3)
{
int modiCorrectWords;
int modiWordsNotFound = _ocrFixEngine.CountUnknownWordsViaDictionary(oneColorText, out modiCorrectWords);
string modiTextOcrFixed = oneColorText;
if (checkBoxAutoFixCommonErrors.Checked)
modiTextOcrFixed = _ocrFixEngine.FixOcrErrors(oneColorText, index, _lastLine, false, checkBoxGuessUnknownWords.Checked);
int modiOcrCorrectedCorrectWords;
int modiOcrCorrectedWordsNotFound = _ocrFixEngine.CountUnknownWordsViaDictionary(modiTextOcrFixed, out modiOcrCorrectedCorrectWords);
if (modiOcrCorrectedWordsNotFound <= modiWordsNotFound)
{
oneColorText = modiTextOcrFixed;
modiWordsNotFound = modiOcrCorrectedWordsNotFound;
modiCorrectWords = modiOcrCorrectedCorrectWords;
}
if (modiWordsNotFound < wordsNotFound || (textWithOutFixes.Length == 1 && modiWordsNotFound == 0))