Optimize nOCR a bit / gray-background-color

This commit is contained in:
Nikolaj Olsson 2020-06-01 18:47:18 +02:00
parent 15175bb072
commit feb59af200
9 changed files with 96 additions and 90 deletions

View File

@ -60,7 +60,7 @@
this.groupBoxInspectItems.Location = new System.Drawing.Point(12, 12);
this.groupBoxInspectItems.Name = "groupBoxInspectItems";
this.groupBoxInspectItems.Size = new System.Drawing.Size(569, 381);
this.groupBoxInspectItems.TabIndex = 4;
this.groupBoxInspectItems.TabIndex = 0;
this.groupBoxInspectItems.TabStop = false;
//
// label1
@ -78,7 +78,7 @@
this.checkBoxItalic.Location = new System.Drawing.Point(253, 130);
this.checkBoxItalic.Name = "checkBoxItalic";
this.checkBoxItalic.Size = new System.Drawing.Size(58, 17);
this.checkBoxItalic.TabIndex = 4;
this.checkBoxItalic.TabIndex = 3;
this.checkBoxItalic.Text = "Is &italic";
this.checkBoxItalic.UseVisualStyleBackColor = true;
//
@ -97,7 +97,7 @@
this.textBoxText.Location = new System.Drawing.Point(252, 102);
this.textBoxText.Name = "textBoxText";
this.textBoxText.Size = new System.Drawing.Size(100, 23);
this.textBoxText.TabIndex = 3;
this.textBoxText.TabIndex = 2;
//
// numericUpDownExpandCount
//
@ -114,7 +114,7 @@
0});
this.numericUpDownExpandCount.Name = "numericUpDownExpandCount";
this.numericUpDownExpandCount.Size = new System.Drawing.Size(63, 20);
this.numericUpDownExpandCount.TabIndex = 2;
this.numericUpDownExpandCount.TabIndex = 1;
this.numericUpDownExpandCount.Value = new decimal(new int[] {
2,
0,
@ -128,7 +128,7 @@
this.labelImageInfo.Location = new System.Drawing.Point(253, 168);
this.labelImageInfo.Name = "labelImageInfo";
this.labelImageInfo.Size = new System.Drawing.Size(45, 13);
this.labelImageInfo.TabIndex = 5;
this.labelImageInfo.TabIndex = 4;
this.labelImageInfo.Text = "Preview";
//
// pictureBoxInspectItem
@ -161,7 +161,7 @@
this.buttonCancel.Location = new System.Drawing.Point(506, 399);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 3;
this.buttonCancel.TabIndex = 2;
this.buttonCancel.Text = "C&ancel";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
@ -174,7 +174,7 @@
this.buttonOK.Location = new System.Drawing.Point(425, 399);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 23);
this.buttonOK.TabIndex = 5;
this.buttonOK.TabIndex = 1;
this.buttonOK.Text = "&OK";
this.buttonOK.UseVisualStyleBackColor = true;
this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);

View File

@ -322,6 +322,7 @@
//
// pictureBoxCharacter
//
this.pictureBoxCharacter.BackColor = System.Drawing.Color.DimGray;
this.pictureBoxCharacter.Location = new System.Drawing.Point(17, 206);
this.pictureBoxCharacter.Name = "pictureBoxCharacter";
this.pictureBoxCharacter.Size = new System.Drawing.Size(99, 47);

View File

@ -78,10 +78,6 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
const int minLineHeight = 6;
_imageList = NikseBitmapImageSplitter.SplitBitmapToLettersNew(nbmp, pixelsIsSpace, rightToLeft, Configuration.Settings.VobSubOcr.TopToBottom, minLineHeight);
foreach (ImageSplitterItem item in _imageList)
{
item.NikseBitmap?.ReplaceTransparentWith(Color.Black);
}
int index = 0;
_indexLookup = new Dictionary<int, int>();
@ -312,7 +308,13 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
using (var vobSubOcrNOcrCharacter = new VobSubOcrNOcrCharacter())
{
vobSubOcrNOcrCharacter.Initialize(_bitmap, img, new Point(0, 0), checkBoxItalic.Checked, expandSelectionList.Count > 1, string.Empty);
var text = string.Empty;
if (_nocrChar.Text != textBoxText.Text)
{
text = textBoxText.Text;
}
vobSubOcrNOcrCharacter.Initialize(_bitmap, img, new Point(0, 0), checkBoxItalic.Checked, expandSelectionList.Count > 1, text);
DialogResult result = vobSubOcrNOcrCharacter.ShowDialog(this);
bool expandSelection = false;
bool shrinkSelection = false;
@ -385,7 +387,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
{
using (var form = new AddBetterMultiMatchNOcr())
{
var tempImageList = new List<ImageSplitterItem>();
var tempImageList = new List<ImageSplitterItem>();
var idx = _indexLookup[listBoxInspectItems.SelectedIndex];
for (int i = idx; i < _imageList.Count; i++)
{

View File

@ -272,6 +272,7 @@
//
// pictureBoxCharacter
//
this.pictureBoxCharacter.BackColor = System.Drawing.Color.DimGray;
this.pictureBoxCharacter.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBoxCharacter.Location = new System.Drawing.Point(197, 142);
this.pictureBoxCharacter.Name = "pictureBoxCharacter";

View File

@ -42,13 +42,13 @@
this.textBoxInputFile = new System.Windows.Forms.TextBox();
this.buttonInputChoose = new System.Windows.Forms.Button();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.label2 = new System.Windows.Forms.Label();
this.textBoxMerged = new System.Windows.Forms.TextBox();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.buttonTrain = new System.Windows.Forms.Button();
this.buttonOK = new System.Windows.Forms.Button();
this.labelInfo = new System.Windows.Forms.Label();
this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
this.label2 = new System.Windows.Forms.Label();
this.textBoxMerged = new System.Windows.Forms.TextBox();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownSegmentsPerCharacter)).BeginInit();
this.groupBox2.SuspendLayout();
@ -70,7 +70,7 @@
this.groupBox1.Location = new System.Drawing.Point(12, 153);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(493, 443);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabIndex = 1;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Training options";
//
@ -83,7 +83,7 @@
this.checkBoxBold.Location = new System.Drawing.Point(9, 420);
this.checkBoxBold.Name = "checkBoxBold";
this.checkBoxBold.Size = new System.Drawing.Size(92, 17);
this.checkBoxBold.TabIndex = 17;
this.checkBoxBold.TabIndex = 7;
this.checkBoxBold.Text = "Also train bold";
this.checkBoxBold.UseVisualStyleBackColor = true;
//
@ -100,7 +100,7 @@
this.listViewFonts.Location = new System.Drawing.Point(9, 47);
this.listViewFonts.Name = "listViewFonts";
this.listViewFonts.Size = new System.Drawing.Size(469, 270);
this.listViewFonts.TabIndex = 16;
this.listViewFonts.TabIndex = 1;
this.listViewFonts.UseCompatibleStateImageBehavior = false;
this.listViewFonts.View = System.Windows.Forms.View.Details;
//
@ -116,7 +116,7 @@
this.label3.Location = new System.Drawing.Point(6, 392);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(189, 13);
this.label3.TabIndex = 16;
this.label3.TabIndex = 5;
this.label3.Text = "Number of line segments per character";
//
// numericUpDownSegmentsPerCharacter
@ -135,7 +135,7 @@
0});
this.numericUpDownSegmentsPerCharacter.Name = "numericUpDownSegmentsPerCharacter";
this.numericUpDownSegmentsPerCharacter.Size = new System.Drawing.Size(66, 20);
this.numericUpDownSegmentsPerCharacter.TabIndex = 15;
this.numericUpDownSegmentsPerCharacter.TabIndex = 6;
this.numericUpDownSegmentsPerCharacter.Value = new decimal(new int[] {
100,
0,
@ -149,7 +149,7 @@
this.checkBoxVeryAccurate.Location = new System.Drawing.Point(9, 367);
this.checkBoxVeryAccurate.Name = "checkBoxVeryAccurate";
this.checkBoxVeryAccurate.Size = new System.Drawing.Size(303, 17);
this.checkBoxVeryAccurate.TabIndex = 14;
this.checkBoxVeryAccurate.TabIndex = 4;
this.checkBoxVeryAccurate.Text = "Very accurate (be less general), require more line segments";
this.checkBoxVeryAccurate.UseVisualStyleBackColor = true;
//
@ -160,7 +160,7 @@
this.labelSubtitleFontSize.Location = new System.Drawing.Point(5, 334);
this.labelSubtitleFontSize.Name = "labelSubtitleFontSize";
this.labelSubtitleFontSize.Size = new System.Drawing.Size(84, 13);
this.labelSubtitleFontSize.TabIndex = 6;
this.labelSubtitleFontSize.TabIndex = 2;
this.labelSubtitleFontSize.Text = "Subtitle font size";
//
// comboBoxSubtitleFontSize
@ -263,7 +263,7 @@
this.comboBoxSubtitleFontSize.Location = new System.Drawing.Point(110, 331);
this.comboBoxSubtitleFontSize.Name = "comboBoxSubtitleFontSize";
this.comboBoxSubtitleFontSize.Size = new System.Drawing.Size(121, 21);
this.comboBoxSubtitleFontSize.TabIndex = 7;
this.comboBoxSubtitleFontSize.TabIndex = 3;
//
// labelSubtitleFont
//
@ -271,7 +271,7 @@
this.labelSubtitleFont.Location = new System.Drawing.Point(6, 31);
this.labelSubtitleFont.Name = "labelSubtitleFont";
this.labelSubtitleFont.Size = new System.Drawing.Size(63, 13);
this.labelSubtitleFont.TabIndex = 4;
this.labelSubtitleFont.TabIndex = 0;
this.labelSubtitleFont.Text = "Subtitle font";
//
// label1
@ -280,7 +280,7 @@
this.label1.Location = new System.Drawing.Point(6, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(272, 13);
this.label1.TabIndex = 8;
this.label1.TabIndex = 0;
this.label1.Text = "Subtitle to train with (must have spaces between letters)";
//
// textBoxInputFile
@ -288,7 +288,7 @@
this.textBoxInputFile.Location = new System.Drawing.Point(8, 40);
this.textBoxInputFile.Name = "textBoxInputFile";
this.textBoxInputFile.Size = new System.Drawing.Size(438, 20);
this.textBoxInputFile.TabIndex = 9;
this.textBoxInputFile.TabIndex = 1;
this.textBoxInputFile.Text = "c:\\data\\SE-OCR\\train.srt";
//
// buttonInputChoose
@ -296,7 +296,7 @@
this.buttonInputChoose.Location = new System.Drawing.Point(452, 37);
this.buttonInputChoose.Name = "buttonInputChoose";
this.buttonInputChoose.Size = new System.Drawing.Size(26, 23);
this.buttonInputChoose.TabIndex = 10;
this.buttonInputChoose.TabIndex = 2;
this.buttonInputChoose.Text = "...";
this.buttonInputChoose.UseVisualStyleBackColor = true;
this.buttonInputChoose.Click += new System.EventHandler(this.buttonInputChoose_Click);
@ -311,10 +311,27 @@
this.groupBox2.Location = new System.Drawing.Point(12, 13);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(493, 134);
this.groupBox2.TabIndex = 14;
this.groupBox2.TabIndex = 0;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Input file";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(7, 82);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(201, 13);
this.label2.TabIndex = 3;
this.label2.Text = "Letter combinations that might be merged";
//
// textBoxMerged
//
this.textBoxMerged.Location = new System.Drawing.Point(9, 98);
this.textBoxMerged.Name = "textBoxMerged";
this.textBoxMerged.Size = new System.Drawing.Size(469, 20);
this.textBoxMerged.TabIndex = 4;
this.textBoxMerged.Text = "ff ft fi fj fy fl rf rt rv rw ry rt ryt tt TV tw yt yw";
//
// openFileDialog1
//
this.openFileDialog1.FileName = "openFileDialog1";
@ -326,7 +343,7 @@
this.buttonTrain.Location = new System.Drawing.Point(296, 602);
this.buttonTrain.Name = "buttonTrain";
this.buttonTrain.Size = new System.Drawing.Size(128, 23);
this.buttonTrain.TabIndex = 16;
this.buttonTrain.TabIndex = 2;
this.buttonTrain.Text = "Start training";
this.buttonTrain.UseVisualStyleBackColor = true;
this.buttonTrain.Click += new System.EventHandler(this.buttonTrain_Click);
@ -337,7 +354,7 @@
this.buttonOK.Location = new System.Drawing.Point(430, 602);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 23);
this.buttonOK.TabIndex = 17;
this.buttonOK.TabIndex = 3;
this.buttonOK.Text = "OK";
this.buttonOK.UseVisualStyleBackColor = true;
this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
@ -349,26 +366,9 @@
this.labelInfo.Location = new System.Drawing.Point(12, 628);
this.labelInfo.Name = "labelInfo";
this.labelInfo.Size = new System.Drawing.Size(47, 13);
this.labelInfo.TabIndex = 19;
this.labelInfo.TabIndex = 4;
this.labelInfo.Text = "labelInfo";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(7, 82);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(201, 13);
this.label2.TabIndex = 11;
this.label2.Text = "Letter combinations that might be merged";
//
// textBoxMerged
//
this.textBoxMerged.Location = new System.Drawing.Point(9, 98);
this.textBoxMerged.Name = "textBoxMerged";
this.textBoxMerged.Size = new System.Drawing.Size(469, 20);
this.textBoxMerged.TabIndex = 12;
this.textBoxMerged.Text = "ff ft fi fj fy fl rf rt rv rw ry rt ryt tt TV tw yt yw";
//
// VobSubNOcrTrain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);

View File

@ -465,10 +465,8 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
{
_ocrMethodModi = comboBoxOcrMethod.Items.Add(language.OcrViaModi);
}
if (Configuration.Settings.General.ShowBetaStuff)
{
_ocrMethodNocr = comboBoxOcrMethod.Items.Add(language.OcrViaNOCR);
}
_ocrMethodNocr = comboBoxOcrMethod.Items.Add(language.OcrViaNOCR);
checkBoxTesseractItalicsOn.Checked = Configuration.Settings.VobSubOcr.UseItalicsInTesseract;
checkBoxTesseractItalicsOn.Text = Configuration.Settings.Language.General.Italic;
@ -3963,7 +3961,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
nbmp.ReplaceNonWhiteWithTransparent();
item.Y += nbmp.CropTopTransparent(0);
nbmp.CropTransparentSidesAndBottom(0, true);
nbmp.ReplaceTransparentWith(Color.Black);
//nbmp.ReplaceTransparentWith(Color.Black);
GetNOcrCompareMatchNew(item, nikseBitmap, _nOcrDb, false, false, list.IndexOf(item), list);
}
}
@ -3989,10 +3987,10 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
}
var list = NikseBitmapImageSplitter.SplitBitmapToLettersNew(nbmpInput, (int)numericUpDownNumberOfPixelsIsSpaceNOCR.Value, checkBoxRightToLeft.Checked, Configuration.Settings.VobSubOcr.TopToBottom, minLineHeight);
foreach (var item in list)
{
item.NikseBitmap?.ReplaceTransparentWith(Color.Black);
}
//foreach (var item in list)
//{
// item.NikseBitmap?.ReplaceTransparentWith(Color.Black);
//}
int index = 0;
bool expandSelection = false;
@ -4015,7 +4013,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
}
item = GetExpandedSelectionNew(nbmpInput, expandSelectionList);
item.NikseBitmap?.ReplaceTransparentWith(Color.Black);
// item.NikseBitmap?.ReplaceTransparentWith(Color.Black);
_vobSubOcrNOcrCharacter.Initialize(bitmap, item, _manualOcrDialogPosition, _italicCheckedLast, expandSelectionList.Count > 1, string.Empty);
var result = _vobSubOcrNOcrCharacter.ShowDialog(this);

View File

@ -240,6 +240,7 @@
//
// pictureBoxCharacter
//
this.pictureBoxCharacter.BackColor = System.Drawing.Color.DimGray;
this.pictureBoxCharacter.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBoxCharacter.Cursor = System.Windows.Forms.Cursors.Cross;
this.pictureBoxCharacter.Location = new System.Drawing.Point(183, 148);
@ -1133,6 +1134,7 @@
//
this.pictureBoxSubtitleImage.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.pictureBoxSubtitleImage.BackColor = System.Drawing.Color.DimGray;
this.pictureBoxSubtitleImage.Location = new System.Drawing.Point(12, 36);
this.pictureBoxSubtitleImage.Name = "pictureBoxSubtitleImage";
this.pictureBoxSubtitleImage.Size = new System.Drawing.Size(604, 205);

View File

@ -74,7 +74,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
listBoxLinesForeground.Items.Clear();
listBoxlinesBackground.Items.Clear();
NikseBitmap nbmp = new NikseBitmap(vobSubImage);
nbmp.ReplaceTransparentWith(Color.Black);
//nbmp.ReplaceTransparentWith(Color.Black);
vobSubImage = nbmp.GetBitmap();
radioButtonHot.Checked = true;
@ -126,6 +126,8 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
Configuration.Settings.VobSubOcr.LineOcrLinesToAutoGuess = (int)numericUpDownLinesToDraw.Value;
buttonGuessAgain_Click(null, null);
};
textBoxCharacters.Focus();
}
private void buttonExpandSelection_Click(object sender, EventArgs e)
@ -142,15 +144,15 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
private bool IsMatch()
{
NikseBitmap nbmp = new NikseBitmap(pictureBoxCharacter.Image as Bitmap);
foreach (NOcrPoint op in NOcrChar.LinesForeground)
var nbmp = new NikseBitmap(pictureBoxCharacter.Image as Bitmap);
foreach (var op in NOcrChar.LinesForeground)
{
foreach (Point point in op.ScaledGetPoints(NOcrChar, nbmp.Width, nbmp.Height))
foreach (var point in op.ScaledGetPoints(NOcrChar, nbmp.Width, nbmp.Height))
{
if (point.X >= 0 && point.Y >= 0 && point.X < nbmp.Width && point.Y < nbmp.Height)
{
Color c = nbmp.GetPixel(point.X, point.Y);
if (c.A > 150 && c.R + 100 + c.G + c.B > VobSubOcr.NocrMinColor)
var c = nbmp.GetPixel(point.X, point.Y);
if (c.A > 150)
{
}
else
@ -160,14 +162,14 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
}
}
}
foreach (NOcrPoint op in NOcrChar.LinesBackground)
foreach (var op in NOcrChar.LinesBackground)
{
foreach (Point point in op.GetPoints())
foreach (var point in op.GetPoints())
{
if (point.X >= 0 && point.Y >= 0 && point.X < nbmp.Width && point.Y < nbmp.Height)
{
Color c = nbmp.GetPixel(point.X, point.Y);
if (c.A > 150 && c.R + 100 + c.G + c.B > VobSubOcr.NocrMinColor)
var c = nbmp.GetPixel(point.X, point.Y);
if (c.A > 150)
{
return false;
}
@ -475,7 +477,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
if (point.X >= 0 && point.Y >= 0 && point.X < nbmp.Width && point.Y < nbmp.Height)
{
Color c = nbmp.GetPixel(point.X, point.Y);
if (c.A > 150 && c.R + 100 + c.G + c.B > VobSubOcr.NocrMinColor)
if (c.A > 150)
{
}
else
@ -488,7 +490,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
if (nbmp.Width > 10 && point.X + 1 < nbmp.Width)
{
c = nbmp.GetPixel(point.X + 1, point.Y);
if (c.A > 150 && c.R + 100 + c.G + c.B > VobSubOcr.NocrMinColor)
if (c.A > 150)
{
}
else
@ -500,7 +502,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
if (nbmp.Width > 10 && point.X >= 1)
{
c = nbmp.GetPixel(point.X - 1, point.Y);
if (c.A > 150 && c.R + 100 + c.G + c.B > VobSubOcr.NocrMinColor)
if (c.A > 150)
{
}
else
@ -512,7 +514,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
if (nbmp.Height > 10 && point.Y + 1 < nbmp.Height)
{
c = nbmp.GetPixel(point.X, point.Y + 1);
if (c.A > 150 && c.R + 100 + c.G + c.B > VobSubOcr.NocrMinColor)
if (c.A > 150)
{
}
else
@ -524,7 +526,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
if (nbmp.Height > 10 && point.Y >= 1)
{
c = nbmp.GetPixel(point.X, point.Y - 1);
if (c.A > 150 && c.R + 100 + c.G + c.B > VobSubOcr.NocrMinColor)
if (c.A > 150)
{
}
else
@ -545,7 +547,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
if (point.X >= 0 && point.Y >= 0 && point.X < nbmp.Width && point.Y < nbmp.Height)
{
Color c = nbmp.GetPixel(point.X, point.Y);
if (c.A > 150 && c.R + 100 + c.G + c.B > VobSubOcr.NocrMinColor)
if (c.A > 150)
{
return false;
}
@ -553,7 +555,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
if (nbmp.Width > 10 && point.X + 1 < nbmp.Width)
{
c = nbmp.GetPixel(point.X + 1, point.Y);
if (c.A > 150 && c.R + 100 + c.G + c.B > VobSubOcr.NocrMinColor)
if (c.A > 150)
{
return false;
}
@ -564,7 +566,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
if (nbmp.Width > 10 && point.X >= 1)
{
c = nbmp.GetPixel(point.X - 1, point.Y);
if (c.A > 150 && c.R + 100 + c.G + c.B > VobSubOcr.NocrMinColor)
if (c.A > 150)
{
return false;
}
@ -573,7 +575,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
if (nbmp.Height > 10 && point.Y + 1 < nbmp.Height)
{
c = nbmp.GetPixel(point.X, point.Y + 1);
if (c.A > 150 && c.R + 100 + c.G + c.B > VobSubOcr.NocrMinColor)
if (c.A > 150)
{
return false;
}
@ -582,7 +584,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
if (nbmp.Height > 10 && point.Y >= 1)
{
c = nbmp.GetPixel(point.X, point.Y - 1);
if (c.A > 150 && c.R + 100 + c.G + c.B > VobSubOcr.NocrMinColor)
if (c.A > 150)
{
return false;
}

View File

@ -106,8 +106,8 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
var p = new Point(point.X + targetItem.X, point.Y + targetItem.Y);
if (p.X >= 0 && p.Y >= 0 && p.X < nikseBitmap.Width && p.Y < nikseBitmap.Height)
{
var c = nikseBitmap.GetPixel(p.X, p.Y);
if (c.A <= 150 || c.R + c.G + c.B <= VobSubOcr.NocrMinColor)
var a = nikseBitmap.GetAlpha(p.X, p.Y);
if (a <= 150)
{
ok = false;
break;
@ -132,8 +132,8 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
var p = new Point(point.X + targetItem.X, point.Y + targetItem.Y);
if (p.X >= 0 && p.Y >= 0 && p.X < nikseBitmap.Width && p.Y < nikseBitmap.Height)
{
var c = nikseBitmap.GetPixel(p.X, p.Y);
if (c.A > 150 && c.R + c.G + c.B > VobSubOcr.NocrMinColor)
var a = nikseBitmap.GetAlpha(p.X, p.Y);
if (a > 150)
{
ok = false;
break;
@ -175,8 +175,8 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
var p = new Point(point.X + targetItem.X, point.Y + targetItem.Y);
if (p.X >= 0 && p.Y >= 0 && p.X < nikseBitmap.Width && p.Y < nikseBitmap.Height)
{
var c = nikseBitmap.GetPixel(p.X, p.Y);
if (c.A <= 150 || c.R + c.G + c.B <= VobSubOcr.NocrMinColor)
var a = nikseBitmap.GetAlpha(p.X, p.Y);
if (a <= 150)
{
ok = false;
break;
@ -201,8 +201,8 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
var p = new Point(point.X + targetItem.X, point.Y + targetItem.Y);
if (p.X >= 0 && p.Y >= 0 && p.X < nikseBitmap.Width && p.Y < nikseBitmap.Height)
{
var c = nikseBitmap.GetPixel(p.X, p.Y);
if (c.A > 150 && c.R + c.G + c.B > VobSubOcr.NocrMinColor)
var a = nikseBitmap.GetAlpha(p.X, p.Y);
if (a > 150)
{
ok = false;
break;
@ -409,8 +409,8 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
{
if (point.X >= 0 && point.Y >= 0 && point.X < bitmap.Width && point.Y < bitmap.Height)
{
var c = bitmap.GetPixel(point.X, point.Y);
if (c.A <= 150 || c.R + c.G + c.B <= VobSubOcr.NocrMinColor)
var a = bitmap.GetAlpha(point.X, point.Y);
if (a <= 150)
{
errors++;
if (errors > errorsAllowed)
@ -432,8 +432,8 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
{
if (point.X >= 0 && point.Y >= 0 && point.X < bitmap.Width && point.Y < bitmap.Height)
{
var c = bitmap.GetPixel(point.X, point.Y);
if (c.A > 150 && c.R + c.G + c.B > VobSubOcr.NocrMinColor)
var a = bitmap.GetAlpha(point.X, point.Y);
if (a > 150)
{
errors++;
if (errors > errorsAllowed)