Fix issue regarding OCR of italic ":" - thx Zoltan :)

This commit is contained in:
Nikolaj Olsson 2017-08-12 16:15:10 +02:00
parent 8dba75db6c
commit ad50fb8cba
3 changed files with 42 additions and 2 deletions

Binary file not shown.

View File

@ -3215,11 +3215,29 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
if (bob.IsPeriod())
{
return new CompareMatch(".", false, 0, null);
ImageSplitterItem next = null;
if (listIndex + 1 < list.Count)
next = list[listIndex + 1];
if (next == null || next.NikseBitmap == null)
return new CompareMatch(".", false, 0, null);
var nextBob = new BinaryOcrBitmap(next.NikseBitmap) { X = next.X, Y = next.Top };
if (!nextBob.IsPeriodAtTop(_binOcrLastLowercaseHeight)) // avoid italic ":"
return new CompareMatch(".", false, 0, null);
}
if (bob.IsComma())
{
return new CompareMatch(",", false, 0, null);
ImageSplitterItem next = null;
if (listIndex + 1 < list.Count)
next = list[listIndex + 1];
if (next == null || next.NikseBitmap == null)
return new CompareMatch(",", false, 0, null);
var nextBob = new BinaryOcrBitmap(next.NikseBitmap) { X = next.X, Y = next.Top };
if (!nextBob.IsPeriodAtTop(_binOcrLastLowercaseHeight)) // avoid italic ";"
return new CompareMatch(",", false, 0, null);
}
if (maxDiff > 0 && bob.IsApostrophe())
{

View File

@ -321,6 +321,28 @@ namespace Nikse.SubtitleEdit.Logic.Ocr.Binary
return true;
}
public bool IsPeriodAtTop(int lowercaseHeight)
{
if (ExpandCount > 0 || Y > lowercaseHeight * 0.7)
return false;
if (Width == 4 && Height == 5 && NumberOfColoredPixels == 20)
return true;
if (Width == 5 && Height == 6 && NumberOfColoredPixels >= 28)
return true;
if (Width == 6 && Height == 7 && NumberOfColoredPixels >= 40)
return true;
if (Width < Height || Width < 5 || Width > 10 || Height < 3 || Height > 9)
{
return false;
}
return true;
}
public bool IsComma()
{
if (ExpandCount > 0 || Y < 20 || Height < Width || Width < 4 || Width > 12 || Height < 8 || Height > 15)