加深文字:LUT分界点从180提到200,文字映射上限从80降到50
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -367,22 +367,20 @@ public static class DocumentScanner
|
||||
Marshal.Copy(resultData, 0, normU8.Data, resultData.Length);
|
||||
|
||||
// --- d: 非线性对比度增强(让文字更黑)---
|
||||
// 除法归一化后文字大约在 180-230 范围(偏亮),需要拉黑
|
||||
// 除法归一化后文字大约在 180-240 范围,需要拉黑
|
||||
// 用 LUT 做分段映射:
|
||||
// 0-180: 线性映射到 0-80(文字区域压暗)
|
||||
// 180-255: 线性映射到 80-255(背景区域保持亮)
|
||||
// 0-200: 线性映射到 0-50(文字区域强力压暗)
|
||||
// 200-255: 线性映射到 50-255(背景区域拉亮)
|
||||
byte[] lut = new byte[256];
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
if (i <= 180)
|
||||
if (i <= 200)
|
||||
{
|
||||
// 文字区域:压暗
|
||||
lut[i] = (byte)(i * 80 / 180);
|
||||
lut[i] = (byte)(i * 50 / 200);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 背景区域:拉亮
|
||||
lut[i] = (byte)(80 + (i - 180) * 175 / 75);
|
||||
lut[i] = (byte)(50 + (i - 200) * 205 / 55);
|
||||
}
|
||||
if (lut[i] > 255) lut[i] = 255;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user