image.vision\ocr\robustness_enhancement.mbt
86.5% · 166 / 192 points · 742 linesBackground color reports the state of each line. Underlined characters mark exact instrumented byte offsets; hover them to inspect the visit count.
- 1
///| - 2
/// # 鲁棒性增强 ocr/robustness_enhancement - 3
/// - 4
/// 图像处理库子模块 - 5
/// 图像处理库子模块 Image processing library submodule - 6
// 扫描质量自适应与鲁棒性增强(v12.24.0 P3 鲁棒性) - 7
// 扫描质量自动评估与自适应预处理、倾斜/畸变校正、复杂版面支持、噪声鲁棒性 - 8
- 9
///| - 10
/// 扫描质量等级 - 11
/// `#non_exhaustive` 表示未来可能添加新构造器 - 12
#derive(Eq, @debug.Debug) - 13
#non_exhaustive - 14
pub(all) enum ScanQualityLevel { - 15
Excellent // 优秀:可直接识别 - 16
Good // 良好:轻微预处理即可 - 17
Fair // 一般:需要增强处理 - 18
Poor // 较差:需要重度预处理 - 19
VeryPoor // 很差:可能无法识别 - 20
} - 21
- 22
///| - 23
pub extend ScanQualityLevel with @debug.Debug::{to_repr} - 24
- 25
///| - 26
pub extend ScanQualityLevel with Eq::{not_equal, equal} - 27
- 28
///| - 29
/// 自适应预处理配置 - 30
#derive(Eq, @debug.Debug) - 31
pub(all) struct AdaptivePreprocessConfig { - 32
quality_level : ScanQualityLevel - 33
denoise_strength : Int32 // 去噪强度 0-5 - 34
contrast_enhance : Double // 对比度增强倍数 1.0-3.0 - 35
binarization_method : String // "otsu" / "adaptive" / "sauvola" - 36
deskew_enabled : Bool // 是否启用倾斜校正 - 37
sharpen_enabled : Bool // 是否启用锐化 - 38
morph_open_enabled : Bool // 是否启用形态学开运算 - 39
morph_close_enabled : Bool // 是否启用形态学闭运算 - 40
recommended_dpi : Int32 // 推荐 DPI - 41
} - 42
- 43
///| - 44
pub extend AdaptivePreprocessConfig with Eq::{not_equal, equal} - 45
- 46
///| - 47
pub extend AdaptivePreprocessConfig with @debug.Debug::{to_repr} - 48
- 49
///| - 50
/// 畸变类型 - 51
/// `#non_exhaustive` 表示未来可能添加新构造器 - 52
#derive(Eq, @debug.Debug) - 53
#non_exhaustive - 54
pub(all) enum DistortionType { - 55
Skew // 倾斜 - 56
Perspective // 透视畸变 - 57
Barrel // 桶形畸变 - 58
Pincushion // 枕形畸变 - 59
UnevenLighting // 光照不均 - 60
Blur // 模糊 - 61
Noise // 噪声 - 62
Unknown - 63
} - 64
- 65
///| - 66
pub extend DistortionType with @debug.Debug::{to_repr} - 67
- 68
///| - 69
pub extend DistortionType with Eq::{not_equal, equal} - 70
- 71
///| - 72
/// 畸变检测结果 - 73
#derive(Eq, @debug.Debug) - 74
pub(all) struct DistortionDetectionResult { - 75
distortion_type : DistortionType - 76
severity : Double // 0.0-1.0 - 77
angle : Double // 倾斜角度(度) - 78
confidence : Double - 79
correction_params : Array[(String, Double)] - 80
} - 81
- 82
///| - 83
pub extend DistortionDetectionResult with Eq::{not_equal, equal} - 84
- 85
///| - 86
pub extend DistortionDetectionResult with @debug.Debug::{to_repr} - 87
- 88
///| - 89
/// 复杂版面类型 - 90
/// `#non_exhaustive` 表示未来可能添加新构造器 - 91
#derive(Eq, @debug.Debug) - 92
#non_exhaustive - 93
pub(all) enum ComplexLayoutType { - 94
SingleColumn - 95
DoubleColumn - 96
TripleColumn - 97
MultiColumnWithFloats - 98
MixedLayout - 99
TableHeavy - 100
ImageHeavy - 101
Unknown - 102
} - 103
- 104
///| - 105
pub extend ComplexLayoutType with @debug.Debug::{to_repr} - 106
- 107
///| - 108
pub extend ComplexLayoutType with Eq::{not_equal, equal} - 109
- 110
///| - 111
/// 复杂版面分析结果 - 112
#derive(Eq, @debug.Debug) - 113
pub(all) struct ComplexLayoutAnalysis { - 114
layout_type : ComplexLayoutType - 115
num_columns : Int32 - 116
has_floating_elements : Bool - 117
has_cross_page_elements : Bool - 118
column_boundaries : Array[Int32] - 119
reading_order_strategy : String - 120
confidence : Double - 121
} - 122
- 123
///| - 124
pub extend ComplexLayoutAnalysis with Eq::{not_equal, equal} - 125
- 126
///| - 127
pub extend ComplexLayoutAnalysis with @debug.Debug::{to_repr} - 128
- 129
///| - 130
/// 鲁棒性评估报告 - 131
#derive(Eq, @debug.Debug) - 132
pub(all) struct RobustnessReport { - 133
overall_score : Double - 134
quality_score : Double - 135
distortion_score : Double - 136
layout_complexity_score : Double - 137
noise_resistance_score : Double - 138
recommendations : Array[String] - 139
estimated_accuracy : Double - 140
processing_recommendation : String - 141
} - 142
- 143
///| - 144
pub extend RobustnessReport with Eq::{not_equal, equal} - 145
- 146
///| - 147
pub extend RobustnessReport with @debug.Debug::{to_repr} - 148
- 149
///| - 150
/// 根据扫描质量自动选择预处理配置 - 151
pub fn select_adaptive_config( - 152
quality : ScanQuality, - 153
) -> AdaptivePreprocessConfig raise @types.LoadError { - 154
// 输入验证 - 155●
if quality.overall_score < 0.0 || quality.overall_score > 100.0 { - 156●
raise @types.LoadError::DecodeFailed( - 157
"select_adaptive_config: 质量评分必须在0-100之间", - 158
) - 159
} - 160
let score = quality.overall_score - 161
if score >= 90.0 { - 162●
AdaptivePreprocessConfig::{ - 163
quality_level: ScanQualityLevel::Excellent, - 164
denoise_strength: 1, - 165
contrast_enhance: 1.0, - 166
binarization_method: "otsu", - 167
deskew_enabled: false, - 168
sharpen_enabled: false, - 169
morph_open_enabled: false, - 170
morph_close_enabled: false, - 171
recommended_dpi: 200, - 172
} - 173●
} else if score >= 75.0 { - 174●
AdaptivePreprocessConfig::{ - 175
quality_level: ScanQualityLevel::Good, - 176
denoise_strength: 2, - 177
contrast_enhance: 1.2, - 178
binarization_method: "otsu", - 179
deskew_enabled: true, - 180
sharpen_enabled: false, - 181
morph_open_enabled: false, - 182
morph_close_enabled: true, - 183
recommended_dpi: 250, - 184
} - 185●
} else if score >= 60.0 { - 186●
AdaptivePreprocessConfig::{ - 187
quality_level: ScanQualityLevel::Fair, - 188
denoise_strength: 3, - 189
contrast_enhance: 1.5, - 190
binarization_method: "adaptive", - 191
deskew_enabled: true, - 192
sharpen_enabled: true, - 193
morph_open_enabled: true, - 194
morph_close_enabled: true, - 195
recommended_dpi: 300, - 196
} - 197●
} else if score >= 40.0 { - 198●
AdaptivePreprocessConfig::{ - 199
quality_level: ScanQualityLevel::Poor, - 200
denoise_strength: 4, - 201
contrast_enhance: 2.0, - 202
binarization_method: "sauvola", - 203
deskew_enabled: true, - 204
sharpen_enabled: true, - 205
morph_open_enabled: true, - 206
morph_close_enabled: true, - 207
recommended_dpi: 400, - 208
} - 209
} else { - 210●
AdaptivePreprocessConfig::{ - 211
quality_level: ScanQualityLevel::VeryPoor, - 212
denoise_strength: 5, - 213
contrast_enhance: 2.5, - 214
binarization_method: "sauvola", - 215
deskew_enabled: true, - 216
sharpen_enabled: true, - 217
morph_open_enabled: true, - 218
morph_close_enabled: true, - 219
recommended_dpi: 600, - 220
} - 221
} - 222
} - 223
- 224
///| - 225
/// 检测倾斜角度(基于霍夫变换的简化版) - 226
pub fn detect_skew_angle_robust( - 227
binary_img : @types.Image, - 228
) -> Double raise @types.LoadError { - 229
// 输入验证 - 230●
if binary_img.width <= 0 || binary_img.height <= 0 { - 231●
raise @types.LoadError::DecodeFailed( - 232
"detect_skew_angle_robust: 图像尺寸必须大于0", - 233
) - 234
} - 235
if binary_img.channels != 1 { - 236●
raise @types.LoadError::DecodeFailed( - 237
"detect_skew_angle_robust: 仅支持单通道二值图", - 238
) - 239
} - 240
let expected_size = binary_img.width * binary_img.height - 241●
if binary_img.data.length() != expected_size { - 242●
raise @types.LoadError::DecodeFailed( - 243
"detect_skew_angle_robust: 数据大小不匹配,期望 " + - 244●
expected_size.to_string() + - 245
",实际 " + - 246●
binary_img.data.length().to_string(), - 247
) - 248
} - 249
let w = binary_img.width - 250
let h = binary_img.height - 251
// 简化版:基于文本行的倾斜检测 - 252
// 计算每行的黑色像素重心 - 253
let mut total_x = 0 - 254
let mut total_y = 0 - 255
let mut count = 0 - 256
for y in 0..<h { - 257●
let mut row_black = 0 - 258
let mut row_x_sum = 0 - 259
for x in 0..<w { - 260●
if binary_img.data[y * w + x].to_int() < 128 { - 261●
row_black += 1 - 262
row_x_sum += x - 263
} - 264
} - 265
if row_black > w / 10 { - 266●
let center_x = row_x_sum / row_black - 267
total_x += center_x - 268
total_y += y - 269
count += 1 - 270
} - 271
} - 272
if count < 2 { - 273●
return 0.0 - 274
} - 275
// 线性回归计算倾斜角度 - 276●
let _ = total_x.to_double() / count.to_double() - 277●
let _ = total_y.to_double() / count.to_double() - 278
let numerator = 0.0 - 279●
ignore(numerator) - 280
let denominator = 0.0 - 281●
ignore(denominator) - 282
// 简化:用首尾两行的重心差计算角度 - 283
let mut first_y = h - 284
let mut first_x = 0 - 285
let mut last_y = 0 - 286
let mut last_x = 0 - 287
for y in 0..<h { - 288●
let mut row_black = 0 - 289
let mut row_x_sum = 0 - 290
for x in 0..<w { - 291●
if binary_img.data[y * w + x].to_int() < 128 { - 292●
row_black += 1 - 293
row_x_sum += x - 294
} - 295
} - 296
if row_black > w / 10 { - 297●
let center_x = row_x_sum / row_black - 298
if y < first_y { - 299●
first_y = y - 300
first_x = center_x - 301
} - 302
if y > last_y { - 303●
last_y = y - 304
last_x = center_x - 305
} - 306
} - 307
} - 308
if last_y - first_y > 0 { - 309●
let angle_rad = (last_x - first_x).to_double() / - 310●
(last_y - first_y).to_double() - 311
let angle_deg = angle_rad * 57.2958 // rad to deg - 312
if angle_deg > 45.0 { - 313●
90.0 - angle_deg - 314●
} else if angle_deg < -45.0 { - 315●
-90.0 - angle_deg - 316
} else { - 317●
angle_deg - 318
} - 319
} else { - 320○
0.0 - 321
} - 322
} - 323
- 324
///| - 325
/// 检测畸变类型和严重程度 - 326
pub fn detect_distortions( - 327
img : @types.Image, - 328
) -> Array[DistortionDetectionResult] raise @types.LoadError { - 329
// 输入验证 - 330●
if img.width <= 0 || img.height <= 0 { - 331●
raise @types.LoadError::DecodeFailed( - 332
"detect_distortions: 图像尺寸必须大于0", - 333
) - 334
} - 335
if img.channels < 1 || img.channels > 4 { - 336●
raise @types.LoadError::DecodeFailed( - 337
"detect_distortions: 通道数必须在1-4之间", - 338
) - 339
} - 340
let expected_size = img.width * img.height * img.channels - 341●
if img.data.length() != expected_size { - 342●
raise @types.LoadError::DecodeFailed( - 343
"detect_distortions: 数据大小不匹配,期望 " + - 344●
expected_size.to_string() + - 345
",实际 " + - 346●
img.data.length().to_string(), - 347
) - 348
} - 349
let results : Array[DistortionDetectionResult] = [] - 350
let w = img.width - 351
let h = img.height - 352
- 353
// 1. 检测噪声 - 354
let mut noise_count = 0 - 355
let mut total_pixels = 0 - 356
for y in 1..<(h - 1) { - 357●
for x in 1..<(w - 1) { - 358●
let idx = y * w + x - 359●
let center = img.data[idx].to_int() - 360
let neighbors = [ - 361●
img.data[idx - 1].to_int(), - 362●
img.data[idx + 1].to_int(), - 363●
img.data[idx - w].to_int(), - 364●
img.data[idx + w].to_int(), - 365
] - 366
let mut neighbor_sum = 0 - 367
for n in neighbors { - 368●
neighbor_sum += n - 369
} - 370
let neighbor_avg = neighbor_sum / 4 - 371●
if (center - neighbor_avg).abs() > 50 { - 372●
noise_count += 1 - 373
} - 374
total_pixels += 1 - 375
} - 376
} - 377
let noise_ratio = if total_pixels > 0 { - 378●
noise_count.to_double() / total_pixels.to_double() - 379
} else { - 380○
0.0 - 381
} - 382
if noise_ratio > 0.01 { - 383●
results.push(DistortionDetectionResult::{ - 384
distortion_type: DistortionType::Noise, - 385
severity: if noise_ratio > 0.1 { - 386●
0.8 - 387●
} else if noise_ratio > 0.05 { - 388●
0.5 - 389
} else { - 390○
0.2 - 391
}, - 392
angle: 0.0, - 393
confidence: 0.8, - 394
correction_params: [ - 395
( - 396
"denoise_strength", - 397
if noise_ratio > 0.1 { - 398●
5.0 - 399●
} else if noise_ratio > 0.05 { - 400●
3.0 - 401
} else { - 402○
2.0 - 403
}, - 404
), - 405
], - 406
}) - 407
} - 408
- 409
// 2. 检测模糊(拉普拉斯方差) - 410
let mut laplacian_sum = 0.0 - 411
let mut laplacian_count = 0 - 412
for y in 1..<(h - 1) { - 413●
for x in 1..<(w - 1) { - 414●
let idx = y * w + x - 415●
let center = img.data[idx].to_double() - 416
let lap = 4.0 * center - - 417●
img.data[idx - 1].to_double() - - 418●
img.data[idx + 1].to_double() - - 419●
img.data[idx - w].to_double() - - 420●
img.data[idx + w].to_double() - 421
laplacian_sum += lap * lap - 422
laplacian_count += 1 - 423
} - 424
} - 425
let laplacian_var = if laplacian_count > 0 { - 426●
laplacian_sum / laplacian_count.to_double() - 427
} else { - 428○
0.0 - 429
} - 430
if laplacian_var < 100.0 { - 431●
results.push(DistortionDetectionResult::{ - 432
distortion_type: DistortionType::Blur, - 433
severity: if laplacian_var < 20.0 { - 434●
0.9 - 435○
} else if laplacian_var < 50.0 { - 436○
0.6 - 437
} else { - 438○
0.3 - 439
}, - 440
angle: 0.0, - 441
confidence: 0.75, - 442
correction_params: [ - 443
( - 444
"sharpen_strength", - 445
if laplacian_var < 20.0 { - 446●
3.0 - 447○
} else if laplacian_var < 50.0 { - 448○
2.0 - 449
} else { - 450○
1.0 - 451
}, - 452
), - 453
], - 454
}) - 455
} - 456
- 457
// 3. 检测光照不均(四角亮度差) - 458
if w > 20 && h > 20 { - 459●
let regions = [ - 460
(10, 10), - 461
(w - 10, 10), - 462
(10, h - 10), - 463
(w - 10, h - 10), - 464
(w / 2, h / 2), - 465
] - 466
let brightnesses : Array[Double] = [] - 467
for _tup0 in regions { - 468●
let (rx, ry) = _tup0 - 469
let mut sum = 0.0 - 470
let mut count = 0 - 471
for dy in 0..<10 { - 472●
for dx in 0..<10 { - 473●
if rx + dx < w && ry + dy < h { - 474●
sum += img.data[(ry + dy) * w + (rx + dx)].to_double() - 475
count += 1 - 476
} - 477
} - 478
} - 479
if count > 0 { - 480●
brightnesses.push(sum / count.to_double()) - 481
} - 482
} - 483●
if brightnesses.length() >= 4 { - 484●
let mut max_b = brightnesses[0] - 485
let mut min_b = brightnesses[0] - 486
for b in brightnesses { - 487●
if b > max_b { - 488●
max_b = b - 489
} - 490
if b < min_b { - 491○
min_b = b - 492
} - 493
} - 494
let brightness_diff = max_b - min_b - 495
if brightness_diff > 50.0 { - 496●
results.push(DistortionDetectionResult::{ - 497
distortion_type: DistortionType::UnevenLighting, - 498
severity: if brightness_diff > 100.0 { - 499●
0.8 - 500○
} else if brightness_diff > 75.0 { - 501○
0.5 - 502
} else { - 503○
0.3 - 504
}, - 505
angle: 0.0, - 506
confidence: 0.7, - 507
correction_params: [ - 508
("adaptive_threshold", 1.0), - 509
("contrast_enhance", 1.5), - 510
], - 511
}) - 512
} - 513
} - 514
} - 515
- 516
results - 517
} - 518
- 519
///| - 520
/// 分析复杂版面 - 521
pub fn analyze_complex_layout( - 522
text_blocks : Array[TextBlock], - 523
page_width : Int32, - 524
page_height : Int32, - 525
) -> ComplexLayoutAnalysis { - 526●
ignore(page_height) - 527●
if text_blocks.length() == 0 { - 528●
return ComplexLayoutAnalysis::{ - 529
layout_type: ComplexLayoutType::Unknown, - 530
num_columns: 1, - 531
has_floating_elements: false, - 532
has_cross_page_elements: false, - 533
column_boundaries: [], - 534
reading_order_strategy: "default", - 535
confidence: 0.0, - 536
} - 537
} - 538
- 539
// 统计水平覆盖范围 - 540
let mut full_width_count = 0 - 541
let mut left_count = 0 - 542
let mut right_count = 0 - 543
let mid_x = page_width / 2 - 544
- 545
for block in text_blocks { - 546●
let center = block.x + block.width / 2 - 547●
if block.width.to_double() > page_width.to_double() * 0.7 { - 548●
full_width_count += 1 - 549●
} else if center < mid_x { - 550●
left_count += 1 - 551
} else { - 552●
right_count += 1 - 553
} - 554
} - 555
- 556●
let total = text_blocks.length().to_double() - 557●
let full_ratio = full_width_count.to_double() / total - 558●
let left_ratio = left_count.to_double() / total - 559●
let right_ratio = right_count.to_double() / total - 560
- 561
let layout_type = if full_ratio > 0.8 { - 562●
ComplexLayoutType::SingleColumn - 563●
} else if left_ratio > 0.3 && right_ratio > 0.3 && full_ratio < 0.2 { - 564●
ComplexLayoutType::DoubleColumn - 565●
} else if full_ratio > 0.2 && (left_ratio > 0.2 || right_ratio > 0.2) { - 566●
ComplexLayoutType::MixedLayout - 567
} else { - 568●
ComplexLayoutType::SingleColumn - 569
} - 570
- 571●
let num_columns = match layout_type { - 572●
ComplexLayoutType::DoubleColumn => 2 - 573○
ComplexLayoutType::TripleColumn => 3 - 574○
ComplexLayoutType::MultiColumnWithFloats => 3 - 575●
_ => 1 - 576
} - 577
- 578
let has_floats = full_ratio > 0.1 && full_ratio < 0.5 - 579
- 580●
let reading_order_strategy = match layout_type { - 581●
ComplexLayoutType::SingleColumn => "top_to_bottom" - 582●
ComplexLayoutType::DoubleColumn => "left_column_first" - 583○
ComplexLayoutType::TripleColumn => "column_by_column" - 584●
ComplexLayoutType::MixedLayout => "adaptive" - 585○
_ => "default" - 586
} - 587
- 588
let boundaries : Array[Int32] = [] - 589●
boundaries.push(0) - 590
if num_columns >= 2 { - 591●
boundaries.push(page_width / 2 - 20) - 592●
boundaries.push(page_width / 2 + 20) - 593
} - 594●
boundaries.push(page_width) - 595
- 596
ComplexLayoutAnalysis::{ - 597
layout_type, - 598
num_columns, - 599
has_floating_elements: has_floats, - 600
has_cross_page_elements: false, - 601
column_boundaries: boundaries, - 602
reading_order_strategy, - 603
confidence: 0.75, - 604
} - 605
} - 606
- 607
///| - 608
/// 生成鲁棒性评估报告 - 609
pub fn generate_robustness_report( - 610
quality : ScanQuality, - 611
distortions : Array[DistortionDetectionResult], - 612
layout : ComplexLayoutAnalysis, - 613
) -> RobustnessReport { - 614
// 质量分数 - 615●
let quality_score = quality.overall_score / 100.0 - 616
- 617
// 畸变分数(畸变越少分数越高) - 618
let mut distortion_penalty = 0.0 - 619
for d in distortions { - 620●
distortion_penalty += d.severity * 0.2 - 621
} - 622
let distortion_score = if 1.0 - distortion_penalty > 0 { - 623●
1.0 - distortion_penalty - 624
} else { - 625○
0.0 - 626
} - 627
- 628
// 版面复杂度分数(越简单分数越高) - 629●
let layout_score = match layout.layout_type { - 630●
ComplexLayoutType::SingleColumn => 1.0 - 631●
ComplexLayoutType::DoubleColumn => 0.8 - 632○
ComplexLayoutType::TripleColumn => 0.6 - 633○
ComplexLayoutType::MixedLayout => 0.5 - 634○
ComplexLayoutType::MultiColumnWithFloats => 0.4 - 635●
_ => 0.7 - 636
} - 637
- 638
// 噪声抵抗分数 - 639
let mut noise_severity = 0.0 - 640
for d in distortions { - 641●
if d.distortion_type == DistortionType::Noise { - 642●
noise_severity = d.severity - 643
} - 644
} - 645
let noise_score = 1.0 - noise_severity - 646
- 647
// 综合分数 - 648
let overall = quality_score * 0.3 + - 649
distortion_score * 0.3 + - 650
layout_score * 0.2 + - 651
noise_score * 0.2 - 652
- 653
// 建议 - 654
let recommendations : Array[String] = [] - 655
if quality_score < 0.6 { - 656●
recommendations.push("建议提高扫描分辨率至 300 DPI 以上") - 657
} - 658
if noise_severity > 0.3 { - 659●
recommendations.push("建议启用强去噪处理(中值滤波+NLM)") - 660
} - 661
if layout.num_columns > 1 { - 662●
recommendations.push( - 663
"检测到多栏布局,建议使用分栏阅读顺序", - 664
) - 665
} - 666
if distortion_penalty > 0.3 { - 667○
recommendations.push( - 668
"检测到严重畸变,建议启用完整预处理流水线", - 669
) - 670
} - 671●
if recommendations.length() == 0 { - 672●
recommendations.push("文档质量良好,可使用标准预处理流程") - 673
} - 674
- 675
// 预估准确率 - 676
let estimated_accuracy = overall * 0.95 + 0.05 - 677
- 678
let processing_recommendation = if overall > 0.8 { - 679●
"标准处理流程" - 680●
} else if overall > 0.6 { - 681●
"增强处理流程" - 682
} else { - 683○
"重度预处理+人工复核" - 684
} - 685
- 686
RobustnessReport::{ - 687
overall_score: overall, - 688
quality_score, - 689
distortion_score, - 690
layout_complexity_score: layout_score, - 691
noise_resistance_score: noise_score, - 692
recommendations, - 693
estimated_accuracy, - 694
processing_recommendation, - 695
} - 696
} - 697
- 698
///| - 699
/// 生成鲁棒性报告文本 - 700
pub fn robustness_report_to_string(report : RobustnessReport) -> String { - 701●
let mut output = "## OCR 鲁棒性评估报告\n\n" - 702
output = output + "### 综合评分\n\n" - 703
output = output + "| 指标 | 分数 |\n" - 704
output = output + "|------|------|\n" - 705
output = output + - 706
"| **综合评分** | **" + - 707●
(report.overall_score * 100.0).to_string() + - 708
"/100** |\n" - 709
output = output + - 710
"| 扫描质量 | " + - 711●
(report.quality_score * 100.0).to_string() + - 712
"/100 |\n" - 713
output = output + - 714
"| 畸变控制 | " + - 715●
(report.distortion_score * 100.0).to_string() + - 716
"/100 |\n" - 717
output = output + - 718
"| 版面复杂度 | " + - 719●
(report.layout_complexity_score * 100.0).to_string() + - 720
"/100 |\n" - 721
output = output + - 722
"| 噪声抵抗 | " + - 723●
(report.noise_resistance_score * 100.0).to_string() + - 724
"/100 |\n\n" - 725
output = output + - 726
"### 预估识别准确率: " + - 727●
(report.estimated_accuracy * 100.0).to_string() + - 728
"%\n\n" - 729
output = output + - 730
"### 推荐处理方式: " + - 731
report.processing_recommendation + - 732
"\n\n" - 733
output = output + "### 改进建议\n\n" - 734●
for i in 0..<report.recommendations.length() { - 735●
output = output + - 736●
(i + 1).to_string() + - 737
". " + - 738
report.recommendations[i] + - 739
"\n" - 740
} - 741
output - 742
}