mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-27 22:42:38 +01:00
Fixed crash in OCR via Image compare with large image databases - thx Zoltan :)
git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@2064 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
parent
24474dce45
commit
f34b3cc6e8
@ -2160,7 +2160,9 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
// check for expand match!
|
// check for expand match!
|
||||||
if (compareItem.ExpandCount > 0 && compareItem.Bitmap.Width > targetItem.Bitmap.Width)
|
if (compareItem.ExpandCount > 0 && compareItem.Bitmap.Width > targetItem.Bitmap.Width)
|
||||||
{
|
{
|
||||||
int dif = ImageSplitter.IsBitmapsAlike(compareItem.Bitmap, ImageSplitter.Copy(parentBitmap, new Rectangle(targetItem.X, targetItem.Y, compareItem.Bitmap.Width, compareItem.Bitmap.Height)));
|
Bitmap cutBitmap = ImageSplitter.Copy(parentBitmap, new Rectangle(targetItem.X, targetItem.Y, compareItem.Bitmap.Width, compareItem.Bitmap.Height));
|
||||||
|
int dif = ImageSplitter.IsBitmapsAlike(compareItem.Bitmap, cutBitmap);
|
||||||
|
cutBitmap.Dispose();
|
||||||
if (dif < smallestDifference)
|
if (dif < smallestDifference)
|
||||||
{
|
{
|
||||||
smallestDifference = dif;
|
smallestDifference = dif;
|
||||||
@ -2196,30 +2198,33 @@ namespace Nikse.SubtitleEdit.Forms
|
|||||||
{
|
{
|
||||||
Bitmap cutBitmap = CopyBitmapSection(target, new Rectangle(1, 0, target.Width - 2, target.Height));
|
Bitmap cutBitmap = CopyBitmapSection(target, new Rectangle(1, 0, target.Width - 2, target.Height));
|
||||||
int topCrop = 0;
|
int topCrop = 0;
|
||||||
cutBitmap = ImageSplitter.CropTopAndBottom(cutBitmap, out topCrop, 2);
|
Bitmap cutBitmap2 = ImageSplitter.CropTopAndBottom(cutBitmap, out topCrop, 2);
|
||||||
if (cutBitmap.Height != target.Height)
|
if (cutBitmap2.Height != target.Height)
|
||||||
FindBestMatch(ref index, ref smallestDifference, ref smallestIndex, cutBitmap);
|
FindBestMatch(ref index, ref smallestDifference, ref smallestIndex, cutBitmap2);
|
||||||
cutBitmap.Dispose();
|
cutBitmap.Dispose();
|
||||||
|
cutBitmap2.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (smallestDifference > 0 && target.Width > 15)
|
if (smallestDifference > 0 && target.Width > 15)
|
||||||
{
|
{
|
||||||
Bitmap cutBitmap = CopyBitmapSection(target, new Rectangle(1, 0, target.Width - 2, target.Height));
|
Bitmap cutBitmap = CopyBitmapSection(target, new Rectangle(1, 0, target.Width - 2, target.Height));
|
||||||
int topCrop = 0;
|
int topCrop = 0;
|
||||||
cutBitmap = ImageSplitter.CropTopAndBottom(cutBitmap, out topCrop);
|
Bitmap cutBitmap2 = ImageSplitter.CropTopAndBottom(cutBitmap, out topCrop);
|
||||||
if (cutBitmap.Height != target.Height)
|
if (cutBitmap2.Height != target.Height)
|
||||||
FindBestMatch(ref index, ref smallestDifference, ref smallestIndex, cutBitmap);
|
FindBestMatch(ref index, ref smallestDifference, ref smallestIndex, cutBitmap2);
|
||||||
cutBitmap.Dispose();
|
cutBitmap.Dispose();
|
||||||
|
cutBitmap2.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (smallestDifference > 0 && target.Width > 15)
|
if (smallestDifference > 0 && target.Width > 15)
|
||||||
{
|
{
|
||||||
Bitmap cutBitmap = CopyBitmapSection(target, new Rectangle(1, 0, target.Width - 2, target.Height));
|
Bitmap cutBitmap = CopyBitmapSection(target, new Rectangle(1, 0, target.Width - 2, target.Height));
|
||||||
int topCrop = 0;
|
int topCrop = 0;
|
||||||
cutBitmap = ImageSplitter.CropTopAndBottom(cutBitmap, out topCrop);
|
Bitmap cutBitmap2 = ImageSplitter.CropTopAndBottom(cutBitmap, out topCrop);
|
||||||
if (cutBitmap.Height != target.Height)
|
if (cutBitmap2.Height != target.Height)
|
||||||
FindBestMatch(ref index, ref smallestDifference, ref smallestIndex, cutBitmap);
|
FindBestMatch(ref index, ref smallestDifference, ref smallestIndex, cutBitmap2);
|
||||||
cutBitmap.Dispose();
|
cutBitmap.Dispose();
|
||||||
|
cutBitmap2.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -592,12 +592,13 @@ namespace Nikse.SubtitleEdit.Logic
|
|||||||
{
|
{
|
||||||
int different = 0;
|
int different = 0;
|
||||||
int maxDiff = (int)(bmp1.Width * bmp1.Height / 5.0);
|
int maxDiff = (int)(bmp1.Width * bmp1.Height / 5.0);
|
||||||
|
NikseBitmap nbmp1 = new NikseBitmap(bmp1);
|
||||||
|
|
||||||
for (int x = 1; x < bmp1.Width; x++)
|
for (int x = 1; x < bmp1.Width; x++)
|
||||||
{
|
{
|
||||||
for (int y = 1; y < bmp1.Height; y++)
|
for (int y = 1; y < bmp1.Height; y++)
|
||||||
{
|
{
|
||||||
if (!IsColorClose(bmp1.GetPixel(x, y), bmp2.GetPixel(x, y), 20))
|
if (!IsColorClose(nbmp1.GetPixel(x, y), bmp2.GetPixel(x, y), 20))
|
||||||
{
|
{
|
||||||
different++;
|
different++;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user