image.domain\forensics\enhanced_source_verification.mbt

91.2% · 271 / 297 points · 1141 lines

Background color reports the state of each line. Underlined characters mark exact instrumented byte offsets; hover them to inspect the visit count.

  1. 1///|
  2. 2/// # 增强来源验证 forensics/enhanced_source_verification
  3. 3///
  4. 4/// 图像处理库子模块
  5. 5/// 图像处理库子模块 Image processing library submodule
  6. 6// 图像来源鉴定增强(v27.1.0)
  7. 7// 增强准确性:UI 元素检测、文字区域检测、几何形状分析、颜色量化分析、智能决策引擎
  8. 8
  9. 9///|
  10. 10/// 增强鉴定结果
  11. 11pub(all) struct EnhancedVerificationResult {
  12. 12 source_type : ImageSourceType
  13. 13 ai_probability : Double
  14. 14 physical_probability : Double
  15. 15 confidence : Double
  16. 16 decision_threshold : Double
  17. 17 basic_features : SourceVerificationFeatures
  18. 18 enhanced_features : EnhancedVerificationFeatures
  19. 19 ui_detection : UIDetectionResult
  20. 20 text_detection : TextDetectionResult
  21. 21 geometry_analysis : GeometryAnalysisResult
  22. 22 color_quantization : ColorQuantizationResult
  23. 23 decision_reason : String
  24. 24 processing_time_ms : Double
  25. 25}
  26. 26
  27. 27///|
  28. 28/// 增强鉴定特征
  29. 29pub(all) struct EnhancedVerificationFeatures {
  30. 30 ui_indicator : Double
  31. 31 text_indicator : Double
  32. 32 geometry_indicator : Double
  33. 33 color_quantization_indicator : Double
  34. 34 solid_area_indicator : Double
  35. 35 edge_direction_indicator : Double
  36. 36 pixel_distribution_indicator : Double
  37. 37 overall_enhanced_score : Double
  38. 38}
  39. 39
  40. 40///|
  41. 41/// UI 检测结果
  42. 42pub(all) struct UIDetectionResult {
  43. 43 has_window_border : Bool
  44. 44 has_toolbar : Bool
  45. 45 has_button_like_elements : Bool
  46. 46 ui_element_count : Int32
  47. 47 ui_area_ratio : Double
  48. 48 horizontal_line_count : Int32
  49. 49 vertical_line_count : Int32
  50. 50 ui_indicator : Double
  51. 51}
  52. 52
  53. 53///|
  54. 54/// 文字检测结果
  55. 55pub(all) struct TextDetectionResult {
  56. 56 text_area_count : Int32
  57. 57 text_area_ratio : Double
  58. 58 dense_edge_region_count : Int32
  59. 59 small_edge_density : Double
  60. 60 text_like_region_ratio : Double
  61. 61 text_indicator : Double
  62. 62}
  63. 63
  64. 64///|
  65. 65/// 几何分析结果
  66. 66pub(all) struct GeometryAnalysisResult {
  67. 67 horizontal_edge_ratio : Double
  68. 68 vertical_edge_ratio : Double
  69. 69 diagonal_edge_ratio : Double
  70. 70 rectangle_like_region_count : Int32
  71. 71 straight_line_count : Int32
  72. 72 geometry_regularity : Double
  73. 73 geometry_indicator : Double
  74. 74}
  75. 75
  76. 76///|
  77. 77/// 颜色量化结果
  78. 78pub(all) struct ColorQuantizationResult {
  79. 79 unique_color_count : Int32
  80. 80 color_quantization_level : Double
  81. 81 top_color_ratio : Double
  82. 82 top_10_color_ratio : Double
  83. 83 color_palette_size : Int32
  84. 84 color_quantization_indicator : Double
  85. 85}
  86. 86
  87. 87///|
  88. 88/// 增强鉴定配置
  89. 89pub(all) struct EnhancedVerificationConfig {
  90. 90 use_ui_detection : Bool
  91. 91 use_text_detection : Bool
  92. 92 use_geometry_analysis : Bool
  93. 93 use_color_quantization : Bool
  94. 94 use_solid_area_analysis : Bool
  95. 95 use_edge_direction_analysis : Bool
  96. 96 basic_weight : Double
  97. 97 enhanced_weight : Double
  98. 98 decision_threshold : Double
  99. 99}
  100. 100
  101. 101///|
  102. 102/// 创建默认增强鉴定配置
  103. 103pub fn create_default_enhanced_verification_config() -> EnhancedVerificationConfig {
  104. 104● EnhancedVerificationConfig::{
  105. 105 use_ui_detection: true,
  106. 106 use_text_detection: true,
  107. 107 use_geometry_analysis: true,
  108. 108 use_color_quantization: true,
  109. 109 use_solid_area_analysis: true,
  110. 110 use_edge_direction_analysis: true,
  111. 111 basic_weight: 0.4,
  112. 112 enhanced_weight: 0.6,
  113. 113 decision_threshold: 0.5,
  114. 114 }
  115. 115}
  116. 116
  117. 117///|
  118. 118/// UI 元素检测
  119. 119pub fn detect_ui_elements(
  120. 120 img : @types.Image,
  121. 121) -> UIDetectionResult raise @types.LoadError {
  122. 122 // 输入验证
  123. 123● if img.width <= 0 || img.height <= 0 {
  124. 124● raise @types.LoadError::DecodeFailed(
  125. 125 "detect_ui_elements: 图像尺寸必须大于0",
  126. 126 )
  127. 127 }
  128. 128 if img.channels < 1 || img.channels > 4 {
  129. 129● raise @types.LoadError::DecodeFailed(
  130. 130 "detect_ui_elements: 通道数必须在1-4之间",
  131. 131 )
  132. 132 }
  133. 133 let expected_size = img.width * img.height * img.channels
  134. 134● if img.data.length() != expected_size {
  135. 135● raise @types.LoadError::DecodeFailed(
  136. 136 "detect_ui_elements: 数据大小不匹配",
  137. 137 )
  138. 138 }
  139. 139 let w = img.width
  140. 140 let h = img.height
  141. 141 let total = w * h
  142. 142
  143. 143 // 检测水平长线(窗口边框、工具栏分隔线)
  144. 144 let mut horizontal_lines = 0
  145. 145 for y in 0..<h {
  146. 146● let mut run_length = 0
  147. 147 for x in 0..<w {
  148. 148● let idx = y * w + x
  149. 149 // 检测边缘像素
  150. 150 let is_edge = if x > 0 && x < w - 1 {
  151. 151● let diff = (img.data[idx].to_double() - img.data[idx - 1].to_double()).abs()
  152. 152 diff > 20.0
  153. 153 } else {
  154. 154● false
  155. 155 }
  156. 156 if is_edge {
  157. 157● run_length += 1
  158. 158 } else {
  159. 159● if run_length > w / 4 {
  160. 160● horizontal_lines += 1
  161. 161 }
  162. 162 run_length = 0
  163. 163 }
  164. 164 }
  165. 165 if run_length > w / 4 {
  166. 166○ horizontal_lines += 1
  167. 167 }
  168. 168 }
  169. 169
  170. 170 // 检测垂直长线
  171. 171 let mut vertical_lines = 0
  172. 172 for x in 0..<w {
  173. 173● let mut run_length = 0
  174. 174 for y in 0..<h {
  175. 175● let idx = y * w + x
  176. 176 let is_edge = if y > 0 && y < h - 1 {
  177. 177● let diff = (img.data[idx].to_double() - img.data[idx - w].to_double()).abs()
  178. 178 diff > 20.0
  179. 179 } else {
  180. 180● false
  181. 181 }
  182. 182 if is_edge {
  183. 183● run_length += 1
  184. 184 } else {
  185. 185● if run_length > h / 4 {
  186. 186● vertical_lines += 1
  187. 187 }
  188. 188 run_length = 0
  189. 189 }
  190. 190 }
  191. 191 if run_length > h / 4 {
  192. 192○ vertical_lines += 1
  193. 193 }
  194. 194 }
  195. 195
  196. 196 // 检测窗口边框(图像四周的边框)
  197. 197 let has_window_border = horizontal_lines >= 2 && vertical_lines >= 2
  198. 198
  199. 199 // 检测工具栏(顶部的密集水平线条区域)
  200. 200 let has_toolbar = horizontal_lines >= 3
  201. 201
  202. 202 // UI 区域比例(有边缘的区域比例)
  203. 203 let mut ui_area = 0
  204. 204 for y in 0..<h {
  205. 205● for x in 0..<w {
  206. 206● let idx = y * w + x
  207. 207 let mut has_edge = false
  208. 208 if x > 0 && x < w - 1 {
  209. 209● if (img.data[idx].to_double() - img.data[idx - 1].to_double()).abs() >
  210. 210 20.0 {
  211. 211● has_edge = true
  212. 212 }
  213. 213 }
  214. 214 if y > 0 && y < h - 1 {
  215. 215● if (img.data[idx].to_double() - img.data[idx - w].to_double()).abs() >
  216. 216 20.0 {
  217. 217● has_edge = true
  218. 218 }
  219. 219 }
  220. 220 if has_edge {
  221. 221● ui_area += 1
  222. 222 }
  223. 223 }
  224. 224 }
  225. 225● let ui_area_ratio = ui_area.to_double() / total.to_double()
  226. 226
  227. 227 // 按钮状元素检测(小矩形区域)
  228. 228 let button_like = horizontal_lines >= 4 && vertical_lines >= 4
  229. 229
  230. 230 // UI 指示值:UI 元素越多,越可能是屏幕截图(物理生成)
  231. 231 let ui_indicator = if has_window_border && has_toolbar {
  232. 232● 0.9
  233. 233● } else if horizontal_lines >= 3 || vertical_lines >= 3 {
  234. 234○ 0.7
  235. 235● } else if horizontal_lines >= 2 || vertical_lines >= 2 {
  236. 236○ 0.5
  237. 237 } else {
  238. 238● 0.2
  239. 239 }
  240. 240
  241. 241 UIDetectionResult::{
  242. 242 has_window_border,
  243. 243 has_toolbar,
  244. 244 has_button_like_elements: button_like,
  245. 245 ui_element_count: horizontal_lines + vertical_lines,
  246. 246 ui_area_ratio,
  247. 247 horizontal_line_count: horizontal_lines,
  248. 248 vertical_line_count: vertical_lines,
  249. 249 ui_indicator,
  250. 250 }
  251. 251}
  252. 252
  253. 253///|
  254. 254/// 文字区域检测
  255. 255pub fn detect_text_regions(
  256. 256 img : @types.Image,
  257. 257) -> TextDetectionResult raise @types.LoadError {
  258. 258 // 输入验证
  259. 259● if img.width <= 0 || img.height <= 0 {
  260. 260● raise @types.LoadError::DecodeFailed(
  261. 261 "detect_text_regions: 图像尺寸必须大于0",
  262. 262 )
  263. 263 }
  264. 264 if img.channels < 1 || img.channels > 4 {
  265. 265● raise @types.LoadError::DecodeFailed(
  266. 266 "detect_text_regions: 通道数必须在1-4之间",
  267. 267 )
  268. 268 }
  269. 269 let expected_size = img.width * img.height * img.channels
  270. 270● if img.data.length() != expected_size {
  271. 271● raise @types.LoadError::DecodeFailed(
  272. 272 "detect_text_regions: 数据大小不匹配",
  273. 273 )
  274. 274 }
  275. 275 let w = img.width
  276. 276 let h = img.height
  277. 277 let total = w * h
  278. 278
  279. 279 // 检测密集小边缘区域(文字特征)
  280. 280 let mut dense_edge_regions = 0
  281. 281 let block_size = 16
  282. 282 let blocks_x = w / block_size
  283. 283 let blocks_y = h / block_size
  284. 284
  285. 285 for by in 0..<blocks_y {
  286. 286● for bx in 0..<blocks_x {
  287. 287● let mut edge_count = 0
  288. 288 for y in 0..<block_size {
  289. 289● for x in 0..<block_size {
  290. 290● let px = bx * block_size + x
  291. 291 let py = by * block_size + y
  292. 292 if px > 0 && px < w - 1 && py > 0 && py < h - 1 {
  293. 293● let idx = py * w + px
  294. 294● let gx = (img.data[idx + 1].to_double() -
  295. 295● img.data[idx - 1].to_double()).abs()
  296. 296● let gy = (img.data[idx + w].to_double() -
  297. 297● img.data[idx - w].to_double()).abs()
  298. 298 if gx > 15.0 || gy > 15.0 {
  299. 299● edge_count += 1
  300. 300 }
  301. 301 }
  302. 302 }
  303. 303 }
  304. 304● let edge_density = edge_count.to_double() /
  305. 305● (block_size * block_size).to_double()
  306. 306 // 文字区域通常边缘密度在 0.15-0.5 之间
  307. 307 if edge_density > 0.15 && edge_density < 0.6 {
  308. 308● dense_edge_regions += 1
  309. 309 }
  310. 310 }
  311. 311 }
  312. 312
  313. 313● let text_area_ratio = dense_edge_regions.to_double() /
  314. 314● (blocks_x * blocks_y).to_double()
  315. 315
  316. 316 // 小边缘密度(全局)
  317. 317 let mut small_edges = 0
  318. 318 for y in 1..<(h - 1) {
  319. 319● for x in 1..<(w - 1) {
  320. 320● let idx = y * w + x
  321. 321● let gx = (img.data[idx + 1].to_double() - img.data[idx - 1].to_double()).abs()
  322. 322● let gy = (img.data[idx + w].to_double() - img.data[idx - w].to_double()).abs()
  323. 323● let mag = (gx * gx + gy * gy).sqrt()
  324. 324 if mag > 10.0 && mag < 80.0 {
  325. 325● small_edges += 1
  326. 326 }
  327. 327 }
  328. 328 }
  329. 329● let small_edge_density = small_edges.to_double() / total.to_double()
  330. 330
  331. 331 // 文字指示值:文字区域越多,越可能是屏幕截图(物理生成)
  332. 332 let text_indicator = if text_area_ratio > 0.15 {
  333. 333● 0.85
  334. 334● } else if text_area_ratio > 0.08 {
  335. 335○ 0.65
  336. 336● } else if text_area_ratio > 0.03 {
  337. 337○ 0.45
  338. 338 } else {
  339. 339● 0.2
  340. 340 }
  341. 341
  342. 342 TextDetectionResult::{
  343. 343 text_area_count: dense_edge_regions,
  344. 344 text_area_ratio,
  345. 345 dense_edge_region_count: dense_edge_regions,
  346. 346 small_edge_density,
  347. 347 text_like_region_ratio: text_area_ratio,
  348. 348 text_indicator,
  349. 349 }
  350. 350}
  351. 351
  352. 352///|
  353. 353/// 几何形状分析
  354. 354pub fn analyze_geometry(
  355. 355 img : @types.Image,
  356. 356) -> GeometryAnalysisResult raise @types.LoadError {
  357. 357 // 输入验证
  358. 358● if img.width <= 0 || img.height <= 0 {
  359. 359● raise @types.LoadError::DecodeFailed(
  360. 360 "analyze_geometry: 图像尺寸必须大于0",
  361. 361 )
  362. 362 }
  363. 363 if img.channels < 1 || img.channels > 4 {
  364. 364● raise @types.LoadError::DecodeFailed(
  365. 365 "analyze_geometry: 通道数必须在1-4之间",
  366. 366 )
  367. 367 }
  368. 368 let expected_size = img.width * img.height * img.channels
  369. 369● if img.data.length() != expected_size {
  370. 370● raise @types.LoadError::DecodeFailed(
  371. 371 "analyze_geometry: 数据大小不匹配",
  372. 372 )
  373. 373 }
  374. 374 let w = img.width
  375. 375 let h = img.height
  376. 376
  377. 377 // 边缘方向分析
  378. 378 let mut horizontal_edges = 0
  379. 379 let mut vertical_edges = 0
  380. 380 let mut diagonal_edges = 0
  381. 381 let mut total_edges = 0
  382. 382
  383. 383 for y in 1..<(h - 1) {
  384. 384● for x in 1..<(w - 1) {
  385. 385● let idx = y * w + x
  386. 386● let gx = img.data[idx + 1].to_double() - img.data[idx - 1].to_double()
  387. 387● let gy = img.data[idx + w].to_double() - img.data[idx - w].to_double()
  388. 388● let mag = (gx * gx + gy * gy).sqrt()
  389. 389 if mag > 20.0 {
  390. 390● total_edges += 1
  391. 391● let abs_gx = gx.abs()
  392. 392● let abs_gy = gy.abs()
  393. 393 if abs_gx > abs_gy * 2.0 {
  394. 394● horizontal_edges += 1
  395. 395● } else if abs_gy > abs_gx * 2.0 {
  396. 396● vertical_edges += 1
  397. 397 } else {
  398. 398● diagonal_edges += 1
  399. 399 }
  400. 400 }
  401. 401 }
  402. 402 }
  403. 403
  404. 404 let horizontal_ratio = if total_edges > 0 {
  405. 405● horizontal_edges.to_double() / total_edges.to_double()
  406. 406 } else {
  407. 407● 0.0
  408. 408 }
  409. 409 let vertical_ratio = if total_edges > 0 {
  410. 410● vertical_edges.to_double() / total_edges.to_double()
  411. 411 } else {
  412. 412● 0.0
  413. 413 }
  414. 414 let diagonal_ratio = if total_edges > 0 {
  415. 415● diagonal_edges.to_double() / total_edges.to_double()
  416. 416 } else {
  417. 417● 0.0
  418. 418 }
  419. 419
  420. 420 // 几何规则性:水平+垂直边缘比例越高,越规则(UI 界面特征)
  421. 421 let geometry_regularity = horizontal_ratio + vertical_ratio
  422. 422
  423. 423 // 矩形状区域检测(规则的水平垂直线条交叉)
  424. 424 let rectangle_regions = if geometry_regularity > 0.7 {
  425. 425● total_edges / 100
  426. 426 } else {
  427. 427● 0
  428. 428 }
  429. 429
  430. 430 // 几何指示值:几何越规则,越可能是屏幕截图(物理生成)
  431. 431 let geometry_indicator = if geometry_regularity > 0.8 {
  432. 432● 0.85
  433. 433● } else if geometry_regularity > 0.65 {
  434. 434● 0.65
  435. 435● } else if geometry_regularity > 0.5 {
  436. 436● 0.45
  437. 437 } else {
  438. 438● 0.25
  439. 439 }
  440. 440
  441. 441 GeometryAnalysisResult::{
  442. 442 horizontal_edge_ratio: horizontal_ratio,
  443. 443 vertical_edge_ratio: vertical_ratio,
  444. 444 diagonal_edge_ratio: diagonal_ratio,
  445. 445 rectangle_like_region_count: rectangle_regions,
  446. 446 straight_line_count: horizontal_edges + vertical_edges,
  447. 447 geometry_regularity,
  448. 448 geometry_indicator,
  449. 449 }
  450. 450}
  451. 451
  452. 452///|
  453. 453/// 颜色量化分析
  454. 454pub fn analyze_color_quantization(
  455. 455 img : @types.Image,
  456. 456) -> ColorQuantizationResult raise @types.LoadError {
  457. 457 // 输入验证
  458. 458● if img.width <= 0 || img.height <= 0 {
  459. 459● raise @types.LoadError::DecodeFailed(
  460. 460 "analyze_color_quantization: 图像尺寸必须大于0",
  461. 461 )
  462. 462 }
  463. 463 if img.channels < 1 || img.channels > 4 {
  464. 464● raise @types.LoadError::DecodeFailed(
  465. 465 "analyze_color_quantization: 通道数必须在1-4之间",
  466. 466 )
  467. 467 }
  468. 468 let expected_size = img.width * img.height * img.channels
  469. 469● if img.data.length() != expected_size {
  470. 470● raise @types.LoadError::DecodeFailed(
  471. 471 "analyze_color_quantization: 数据大小不匹配",
  472. 472 )
  473. 473 }
  474. 474 let w = img.width
  475. 475 let h = img.height
  476. 476 let total = w * h
  477. 477
  478. 478 // 统计唯一颜色数量(量化到 64 级)
  479. 479 let color_histogram : Array[Int32] = []
  480. 480 for _ in 0..<64 {
  481. 481● color_histogram.push(0)
  482. 482 }
  483. 483 for i in 0..<total {
  484. 484● let bin = img.data[i].to_int() * 64 / 256
  485. 485 color_histogram[bin] += 1
  486. 486 }
  487. 487
  488. 488 let mut unique_colors = 0
  489. 489 for i in 0..<64 {
  490. 490● if color_histogram[i] > 0 {
  491. 491● unique_colors += 1
  492. 492 }
  493. 493 }
  494. 494
  495. 495 // 顶部颜色比例
  496. 496 let sorted_colors : Array[Int32] = []
  497. 497 for i in 0..<64 {
  498. 498● sorted_colors.push(color_histogram[i])
  499. 499 }
  500. 500 // 冒泡排序
  501. 501 for i in 0..<64 {
  502. 502● for j in 0..<(64 - i - 1) {
  503. 503● if sorted_colors[j] < sorted_colors[j + 1] {
  504. 504● let temp = sorted_colors[j]
  505. 505 sorted_colors[j] = sorted_colors[j + 1]
  506. 506 sorted_colors[j + 1] = temp
  507. 507 }
  508. 508 }
  509. 509 }
  510. 510
  511. 511 let top_color_ratio = if total > 0 {
  512. 512● sorted_colors[0].to_double() / total.to_double()
  513. 513 } else {
  514. 514○ 0.0
  515. 515 }
  516. 516 let mut top_10_sum = 0
  517. 517 for i in 0..<10 {
  518. 518● top_10_sum += sorted_colors[i]
  519. 519 }
  520. 520 let top_10_ratio = if total > 0 {
  521. 521● top_10_sum.to_double() / total.to_double()
  522. 522 } else {
  523. 523○ 0.0
  524. 524 }
  525. 525
  526. 526 // 颜色量化级别:唯一颜色越少,量化越严重(UI 界面特征)
  527. 527● let quantization_level = 1.0 - unique_colors.to_double() / 64.0
  528. 528
  529. 529 // 颜色调色板大小(估计)
  530. 530 let palette_size = unique_colors
  531. 531
  532. 532 // 颜色量化指示值:颜色越集中,越可能是屏幕截图(物理生成)
  533. 533 let color_quantization_indicator = if top_10_ratio > 0.8 {
  534. 534● 0.85
  535. 535● } else if top_10_ratio > 0.65 {
  536. 536○ 0.65
  537. 537● } else if top_10_ratio > 0.5 {
  538. 538○ 0.45
  539. 539 } else {
  540. 540● 0.25
  541. 541 }
  542. 542
  543. 543 ColorQuantizationResult::{
  544. 544 unique_color_count: unique_colors,
  545. 545 color_quantization_level: quantization_level,
  546. 546 top_color_ratio,
  547. 547 top_10_color_ratio: top_10_ratio,
  548. 548 color_palette_size: palette_size,
  549. 549 color_quantization_indicator,
  550. 550 }
  551. 551}
  552. 552
  553. 553///|
  554. 554/// 纯色区域分析
  555. 555pub fn analyze_solid_areas(img : @types.Image) -> Double raise @types.LoadError {
  556. 556 // 输入验证
  557. 557● if img.width <= 0 || img.height <= 0 {
  558. 558● raise @types.LoadError::DecodeFailed(
  559. 559 "analyze_solid_areas: 图像尺寸必须大于0",
  560. 560 )
  561. 561 }
  562. 562 if img.channels < 1 || img.channels > 4 {
  563. 563● raise @types.LoadError::DecodeFailed(
  564. 564 "analyze_solid_areas: 通道数必须在1-4之间",
  565. 565 )
  566. 566 }
  567. 567 let expected_size = img.width * img.height * img.channels
  568. 568● if img.data.length() != expected_size {
  569. 569● raise @types.LoadError::DecodeFailed(
  570. 570 "analyze_solid_areas: 数据大小不匹配",
  571. 571 )
  572. 572 }
  573. 573 let w = img.width
  574. 574 let h = img.height
  575. 575 let _ = w * h
  576. 576 let block_size = 8
  577. 577 let mut solid_blocks = 0
  578. 578 let total_blocks = w / block_size * (h / block_size)
  579. 579
  580. 580 for by in 0..<(h / block_size) {
  581. 581● for bx in 0..<(w / block_size) {
  582. 582● let mut min_val = 255
  583. 583 let mut max_val = 0
  584. 584 for y in 0..<block_size {
  585. 585● for x in 0..<block_size {
  586. 586● let px = bx * block_size + x
  587. 587 let py = by * block_size + y
  588. 588● let val = img.data[py * w + px].to_int()
  589. 589 if val < min_val {
  590. 590● min_val = val
  591. 591 }
  592. 592 if val > max_val {
  593. 593● max_val = val
  594. 594 }
  595. 595 }
  596. 596 }
  597. 597 if max_val - min_val < 10 {
  598. 598● solid_blocks += 1
  599. 599 }
  600. 600 }
  601. 601 }
  602. 602
  603. 603 let solid_ratio = if total_blocks > 0 {
  604. 604● solid_blocks.to_double() / total_blocks.to_double()
  605. 605 } else {
  606. 606○ 0.0
  607. 607 }
  608. 608
  609. 609 // 纯色区域指示值:纯色区域越多,越可能是屏幕截图(物理生成)
  610. 610 if solid_ratio > 0.5 {
  611. 611● 0.8
  612. 612● } else if solid_ratio > 0.35 {
  613. 613○ 0.6
  614. 614● } else if solid_ratio > 0.2 {
  615. 615○ 0.4
  616. 616 } else {
  617. 617● 0.2
  618. 618 }
  619. 619}
  620. 620
  621. 621///|
  622. 622/// 边缘方向分析
  623. 623pub fn analyze_edge_directions(
  624. 624 img : @types.Image,
  625. 625) -> Double raise @types.LoadError {
  626. 626 // 输入验证
  627. 627● if img.width <= 0 || img.height <= 0 {
  628. 628● raise @types.LoadError::DecodeFailed(
  629. 629 "analyze_edge_directions: 图像尺寸必须大于0",
  630. 630 )
  631. 631 }
  632. 632 if img.channels < 1 || img.channels > 4 {
  633. 633● raise @types.LoadError::DecodeFailed(
  634. 634 "analyze_edge_directions: 通道数必须在1-4之间",
  635. 635 )
  636. 636 }
  637. 637 let expected_size = img.width * img.height * img.channels
  638. 638● if img.data.length() != expected_size {
  639. 639● raise @types.LoadError::DecodeFailed(
  640. 640 "analyze_edge_directions: 数据大小不匹配",
  641. 641 )
  642. 642 }
  643. 643● let geometry = analyze_geometry(img)
  644. 644 // 水平+垂直边缘比例越高,越可能是 UI 界面(物理生成)
  645. 645 let hv_ratio = geometry.horizontal_edge_ratio + geometry.vertical_edge_ratio
  646. 646 if hv_ratio > 0.8 {
  647. 647● 0.8
  648. 648● } else if hv_ratio > 0.65 {
  649. 649● 0.6
  650. 650● } else if hv_ratio > 0.5 {
  651. 651● 0.4
  652. 652 } else {
  653. 653● 0.2
  654. 654 }
  655. 655}
  656. 656
  657. 657///|
  658. 658/// 像素值分布分析
  659. 659pub fn analyze_pixel_distribution(
  660. 660 img : @types.Image,
  661. 661) -> Double raise @types.LoadError {
  662. 662 // 输入验证
  663. 663● if img.width <= 0 || img.height <= 0 {
  664. 664● raise @types.LoadError::DecodeFailed(
  665. 665 "analyze_pixel_distribution: 图像尺寸必须大于0",
  666. 666 )
  667. 667 }
  668. 668 if img.channels < 1 || img.channels > 4 {
  669. 669● raise @types.LoadError::DecodeFailed(
  670. 670 "analyze_pixel_distribution: 通道数必须在1-4之间",
  671. 671 )
  672. 672 }
  673. 673 let expected_size = img.width * img.height * img.channels
  674. 674● if img.data.length() != expected_size {
  675. 675● raise @types.LoadError::DecodeFailed(
  676. 676 "analyze_pixel_distribution: 数据大小不匹配",
  677. 677 )
  678. 678 }
  679. 679 let w = img.width
  680. 680 let h = img.height
  681. 681 let total = w * h
  682. 682
  683. 683 // 计算像素值分布的熵
  684. 684 let histogram : Array[Int32] = []
  685. 685 for _ in 0..<256 {
  686. 686● histogram.push(0)
  687. 687 }
  688. 688 for i in 0..<total {
  689. 689● histogram[img.data[i].to_int()] += 1
  690. 690 }
  691. 691
  692. 692 let mut entropy = 0.0
  693. 693 for i in 0..<256 {
  694. 694● if histogram[i] > 0 {
  695. 695● let p = histogram[i].to_double() / total.to_double()
  696. 696 entropy -= p * p * 0.1 // 简化的 log2
  697. 697 }
  698. 698 }
  699. 699
  700. 700 // 像素分布越集中(熵越低),越可能是 UI 界面(物理生成)
  701. 701 if entropy < 0.5 {
  702. 702● 0.75
  703. 703○ } else if entropy < 1.0 {
  704. 704○ 0.55
  705. 705○ } else if entropy < 1.5 {
  706. 706○ 0.35
  707. 707 } else {
  708. 708○ 0.2
  709. 709 }
  710. 710}
  711. 711
  712. 712///|
  713. 713/// 智能决策引擎
  714. 714pub fn intelligent_decision(
  715. 715 basic_result : SourceVerificationResult,
  716. 716 ui_result : UIDetectionResult,
  717. 717 text_result : TextDetectionResult,
  718. 718 geometry_result : GeometryAnalysisResult,
  719. 719 color_result : ColorQuantizationResult,
  720. 720 solid_indicator : Double,
  721. 721 edge_dir_indicator : Double,
  722. 722 pixel_dist_indicator : Double,
  723. 723 config : EnhancedVerificationConfig,
  724. 724) -> (ImageSourceType, Double, Double, Double, String) {
  725. 725 // 增强特征的物理生成指示值(值越高越可能是物理生成)
  726. 726● let enhanced_physical_score = ui_result.ui_indicator * 0.25 +
  727. 727 text_result.text_indicator * 0.20 +
  728. 728 geometry_result.geometry_indicator * 0.15 +
  729. 729 color_result.color_quantization_indicator * 0.15 +
  730. 730 solid_indicator * 0.10 +
  731. 731 edge_dir_indicator * 0.08 +
  732. 732 pixel_dist_indicator * 0.07
  733. 733
  734. 734 // 基础特征的 AI 生成指示值
  735. 735 let basic_ai_score = basic_result.ai_probability
  736. 736
  737. 737 // 加权融合
  738. 738 let final_ai_score = basic_ai_score * config.basic_weight +
  739. 739 (1.0 - enhanced_physical_score) * config.enhanced_weight
  740. 740 let final_physical_score = 1.0 - final_ai_score
  741. 741
  742. 742 // 智能决策规则
  743. 743 let mut decision_reason = ""
  744. 744 let mut source_type = ImageSourceType::Unknown
  745. 745 let mut confidence = 0.0
  746. 746
  747. 747 // 强 UI 特征判定
  748. 748 if ui_result.has_window_border &&
  749. 749 ui_result.has_toolbar &&
  750. 750 text_result.text_area_ratio > 0.05 {
  751. 751● source_type = ImageSourceType::PhysicalCaptured
  752. 752 confidence = 0.9
  753. 753 decision_reason = "检测到窗口边框、工具栏和文字区域,强烈判定为屏幕截图(物理生成)"
  754. 754● } else if ui_result.ui_element_count >= 6 &&
  755. 755 geometry_result.geometry_regularity > 0.7 {
  756. 756○ source_type = ImageSourceType::PhysicalCaptured
  757. 757 confidence = 0.8
  758. 758 decision_reason = "检测到大量 UI 元素和规则几何形状,判定为屏幕截图(物理生成)"
  759. 759● } else if text_result.text_area_ratio > 0.1 &&
  760. 760 color_result.top_10_color_ratio > 0.7 {
  761. 761● source_type = ImageSourceType::PhysicalCaptured
  762. 762 confidence = 0.75
  763. 763 decision_reason = "检测到大量文字区域和集中的颜色分布,判定为屏幕截图(物理生成)"
  764. 764● } else if enhanced_physical_score > 0.65 {
  765. 765○ source_type = ImageSourceType::PhysicalCaptured
  766. 766 confidence = 0.7
  767. 767 decision_reason = "增强特征综合评分偏向物理生成,判定为物理生成"
  768. 768● } else if final_ai_score >= config.decision_threshold &&
  769. 769 enhanced_physical_score < 0.4 {
  770. 770● source_type = ImageSourceType::AIGenerated
  771. 771● confidence = if final_ai_score > 0.7 { 0.75 } else { 0.55 }
  772. 772 decision_reason = "基础特征和增强特征均偏向 AI 生成,判定为 AI 生成"
  773. 773● } else if final_ai_score >= config.decision_threshold {
  774. 774● source_type = ImageSourceType::AIGenerated
  775. 775 confidence = 0.45
  776. 776 decision_reason = "基础特征偏向 AI 生成,但增强特征存在不确定性,低置信度判定为 AI 生成"
  777. 777 } else {
  778. 778● source_type = ImageSourceType::PhysicalCaptured
  779. 779 confidence = 0.55
  780. 780 decision_reason = "综合特征偏向物理生成,判定为物理生成"
  781. 781 }
  782. 782
  783. 783 (
  784. 784 source_type, final_ai_score, final_physical_score, confidence, decision_reason,
  785. 785 )
  786. 786}
  787. 787
  788. 788///|
  789. 789/// 增强图像来源鉴定
  790. 790pub fn verify_image_source_enhanced(
  791. 791 img : @types.Image,
  792. 792 config : EnhancedVerificationConfig,
  793. 793) -> EnhancedVerificationResult raise @types.LoadError {
  794. 794 // 输入验证
  795. 795● if img.width <= 0 || img.height <= 0 {
  796. 796● raise @types.LoadError::DecodeFailed(
  797. 797 "verify_image_source_enhanced: 图像尺寸必须大于0",
  798. 798 )
  799. 799 }
  800. 800 if img.channels < 1 || img.channels > 4 {
  801. 801● raise @types.LoadError::DecodeFailed(
  802. 802 "verify_image_source_enhanced: 通道数必须在1-4之间",
  803. 803 )
  804. 804 }
  805. 805 let expected_size = img.width * img.height * img.channels
  806. 806● if img.data.length() != expected_size {
  807. 807● raise @types.LoadError::DecodeFailed(
  808. 808 "verify_image_source_enhanced: 数据大小不匹配",
  809. 809 )
  810. 810 }
  811. 811 // 基础鉴定
  812. 812● let basic_config = create_default_source_verification_config()
  813. 813● let basic_result = verify_image_source(img, basic_config)
  814. 814
  815. 815 // UI 检测
  816. 816 let ui_result = if config.use_ui_detection {
  817. 817● detect_ui_elements(img)
  818. 818 } else {
  819. 819● UIDetectionResult::{
  820. 820 has_window_border: false,
  821. 821 has_toolbar: false,
  822. 822 has_button_like_elements: false,
  823. 823 ui_element_count: 0,
  824. 824 ui_area_ratio: 0.0,
  825. 825 horizontal_line_count: 0,
  826. 826 vertical_line_count: 0,
  827. 827 ui_indicator: 0.5,
  828. 828 }
  829. 829 }
  830. 830
  831. 831 // 文字检测
  832. 832 let text_result = if config.use_text_detection {
  833. 833● detect_text_regions(img)
  834. 834 } else {
  835. 835● TextDetectionResult::{
  836. 836 text_area_count: 0,
  837. 837 text_area_ratio: 0.0,
  838. 838 dense_edge_region_count: 0,
  839. 839 small_edge_density: 0.0,
  840. 840 text_like_region_ratio: 0.0,
  841. 841 text_indicator: 0.5,
  842. 842 }
  843. 843 }
  844. 844
  845. 845 // 几何分析
  846. 846 let geometry_result = if config.use_geometry_analysis {
  847. 847● analyze_geometry(img)
  848. 848 } else {
  849. 849● GeometryAnalysisResult::{
  850. 850 horizontal_edge_ratio: 0.5,
  851. 851 vertical_edge_ratio: 0.5,
  852. 852 diagonal_edge_ratio: 0.0,
  853. 853 rectangle_like_region_count: 0,
  854. 854 straight_line_count: 0,
  855. 855 geometry_regularity: 1.0,
  856. 856 geometry_indicator: 0.5,
  857. 857 }
  858. 858 }
  859. 859
  860. 860 // 颜色量化分析
  861. 861 let color_result = if config.use_color_quantization {
  862. 862● analyze_color_quantization(img)
  863. 863 } else {
  864. 864● ColorQuantizationResult::{
  865. 865 unique_color_count: 32,
  866. 866 color_quantization_level: 0.5,
  867. 867 top_color_ratio: 0.1,
  868. 868 top_10_color_ratio: 0.5,
  869. 869 color_palette_size: 32,
  870. 870 color_quantization_indicator: 0.5,
  871. 871 }
  872. 872 }
  873. 873
  874. 874 // 纯色区域分析
  875. 875 let solid_indicator = if config.use_solid_area_analysis {
  876. 876● analyze_solid_areas(img)
  877. 877 } else {
  878. 878● 0.5
  879. 879 }
  880. 880
  881. 881 // 边缘方向分析
  882. 882 let edge_dir_indicator = if config.use_edge_direction_analysis {
  883. 883● analyze_edge_directions(img)
  884. 884 } else {
  885. 885● 0.5
  886. 886 }
  887. 887
  888. 888 // 像素值分布分析
  889. 889● let pixel_dist_indicator = analyze_pixel_distribution(img)
  890. 890
  891. 891 // 增强特征综合评分
  892. 892 let enhanced_overall = ui_result.ui_indicator * 0.25 +
  893. 893 text_result.text_indicator * 0.20 +
  894. 894 geometry_result.geometry_indicator * 0.15 +
  895. 895 color_result.color_quantization_indicator * 0.15 +
  896. 896 solid_indicator * 0.10 +
  897. 897 edge_dir_indicator * 0.08 +
  898. 898 pixel_dist_indicator * 0.07
  899. 899
  900. 900 let enhanced_features = EnhancedVerificationFeatures::{
  901. 901 ui_indicator: ui_result.ui_indicator,
  902. 902 text_indicator: text_result.text_indicator,
  903. 903 geometry_indicator: geometry_result.geometry_indicator,
  904. 904 color_quantization_indicator: color_result.color_quantization_indicator,
  905. 905 solid_area_indicator: solid_indicator,
  906. 906 edge_direction_indicator: edge_dir_indicator,
  907. 907 pixel_distribution_indicator: pixel_dist_indicator,
  908. 908 overall_enhanced_score: enhanced_overall,
  909. 909 }
  910. 910
  911. 911 // 智能决策
  912. 912● let (source_type, ai_prob, physical_prob, confidence, reason) = intelligent_decision(
  913. 913 basic_result, ui_result, text_result, geometry_result, color_result, solid_indicator,
  914. 914 edge_dir_indicator, pixel_dist_indicator, config,
  915. 915 )
  916. 916
  917. 917 EnhancedVerificationResult::{
  918. 918 source_type,
  919. 919 ai_probability: ai_prob,
  920. 920 physical_probability: physical_prob,
  921. 921 confidence,
  922. 922 decision_threshold: config.decision_threshold,
  923. 923 basic_features: basic_result.features,
  924. 924 enhanced_features,
  925. 925 ui_detection: ui_result,
  926. 926 text_detection: text_result,
  927. 927 geometry_analysis: geometry_result,
  928. 928 color_quantization: color_result,
  929. 929 decision_reason: reason,
  930. 930 processing_time_ms: 0.0,
  931. 931 }
  932. 932}
  933. 933
  934. 934///|
  935. 935/// 生成增强鉴定报告
  936. 936pub fn enhanced_verification_report_to_string(
  937. 937 result : EnhancedVerificationResult,
  938. 938) -> String {
  939. 939● let mut report = "## 图像来源鉴定报告(增强版)\n\n"
  940. 940 report = report + "### 鉴定结论\n\n"
  941. 941 report = report + "| 指标 | 值 |\n|------|------|\n"
  942. 942 let source_str = if result.source_type == ImageSourceType::AIGenerated {
  943. 943● "AI 生成"
  944. 944● } else if result.source_type == ImageSourceType::PhysicalCaptured {
  945. 945● "物理生成(真实拍摄/屏幕截图)"
  946. 946○ } else if result.source_type == ImageSourceType::Unknown {
  947. 947○ "未知"
  948. 948 } else {
  949. 949○ "混合"
  950. 950 }
  951. 951 report = report + "| 来源类型 | " + source_str + " |\n"
  952. 952 report = report +
  953. 953 "| AI 生成概率 | " +
  954. 954● (result.ai_probability * 100.0).to_string() +
  955. 955 "% |\n"
  956. 956 report = report +
  957. 957 "| 物理生成概率 | " +
  958. 958● (result.physical_probability * 100.0).to_string() +
  959. 959 "% |\n"
  960. 960 report = report +
  961. 961 "| 置信度 | " +
  962. 962● (result.confidence * 100.0).to_string() +
  963. 963 "% |\n"
  964. 964 report = report + "| 决策依据 | " + result.decision_reason + " |\n\n"
  965. 965
  966. 966 report = report + "### 基础特征分析\n\n"
  967. 967 report = report + "| 特征 | AI 指示值 |\n|------|-----------|\n"
  968. 968 report = report +
  969. 969 "| 噪声模式 | " +
  970. 970● (result.basic_features.noise_pattern_score * 100.0).to_string() +
  971. 971 "% |\n"
  972. 972 report = report +
  973. 973 "| 频域特征 | " +
  974. 974● (result.basic_features.frequency_domain_score * 100.0).to_string() +
  975. 975 "% |\n"
  976. 976 report = report +
  977. 977 "| 颜色分布 | " +
  978. 978● (result.basic_features.color_distribution_score * 100.0).to_string() +
  979. 979 "% |\n"
  980. 980 report = report +
  981. 981 "| 纹理特征 | " +
  982. 982● (result.basic_features.texture_score * 100.0).to_string() +
  983. 983 "% |\n"
  984. 984 report = report +
  985. 985 "| 边缘特征 | " +
  986. 986● (result.basic_features.edge_score * 100.0).to_string() +
  987. 987 "% |\n"
  988. 988 report = report +
  989. 989 "| 压缩伪影 | " +
  990. 990● (result.basic_features.compression_artifact_score * 100.0).to_string() +
  991. 991 "% |\n"
  992. 992 report = report +
  993. 993 "| 细节特征 | " +
  994. 994● (result.basic_features.detail_score * 100.0).to_string() +
  995. 995 "% |\n"
  996. 996 report = report +
  997. 997 "| 基础综合 | " +
  998. 998● (result.basic_features.overall_score * 100.0).to_string() +
  999. 999 "% |\n\n"
  1000. 1000
  1001. 1001 report = report + "### 增强特征分析\n\n"
  1002. 1002 report = report +
  1003. 1003 "| 特征 | 物理生成指示值 | 说明 |\n|------|---------------|------|\n"
  1004. 1004 report = report +
  1005. 1005 "| UI 元素检测 | " +
  1006. 1006● (result.enhanced_features.ui_indicator * 100.0).to_string() +
  1007. 1007 "% | 窗口边框/工具栏/按钮检测 |\n"
  1008. 1008 report = report +
  1009. 1009 "| 文字区域检测 | " +
  1010. 1010● (result.enhanced_features.text_indicator * 100.0).to_string() +
  1011. 1011 "% | 密集小边缘区域检测 |\n"
  1012. 1012 report = report +
  1013. 1013 "| 几何形状分析 | " +
  1014. 1014● (result.enhanced_features.geometry_indicator * 100.0).to_string() +
  1015. 1015 "% | 水平/垂直边缘比例 |\n"
  1016. 1016 report = report +
  1017. 1017 "| 颜色量化分析 | " +
  1018. 1018● (result.enhanced_features.color_quantization_indicator * 100.0).to_string() +
  1019. 1019 "% | 颜色集中度/调色板大小 |\n"
  1020. 1020 report = report +
  1021. 1021 "| 纯色区域分析 | " +
  1022. 1022● (result.enhanced_features.solid_area_indicator * 100.0).to_string() +
  1023. 1023 "% | 大面积纯色区域比例 |\n"
  1024. 1024 report = report +
  1025. 1025 "| 边缘方向分析 | " +
  1026. 1026● (result.enhanced_features.edge_direction_indicator * 100.0).to_string() +
  1027. 1027 "% | 水平+垂直边缘占比 |\n"
  1028. 1028 report = report +
  1029. 1029 "| 像素分布分析 | " +
  1030. 1030● (result.enhanced_features.pixel_distribution_indicator * 100.0).to_string() +
  1031. 1031 "% | 像素值分布熵 |\n"
  1032. 1032 report = report +
  1033. 1033 "| 增强综合 | " +
  1034. 1034● (result.enhanced_features.overall_enhanced_score * 100.0).to_string() +
  1035. 1035 "% | 加权综合评分 |\n\n"
  1036. 1036
  1037. 1037 report = report + "### UI 检测详情\n\n"
  1038. 1038 report = report + "| 指标 | 值 |\n|------|------|\n"
  1039. 1039 report = report +
  1040. 1040 "| 窗口边框 | " +
  1041. 1041 (if result.ui_detection.has_window_border {
  1042. 1042○ "检测到"
  1043. 1043 } else {
  1044. 1044● "未检测到"
  1045. 1045 }) +
  1046. 1046 " |\n"
  1047. 1047 report = report +
  1048. 1048 "| 工具栏 | " +
  1049. 1049◐ (if result.ui_detection.has_toolbar { "检测到" } else { "未检测到" }) +
  1050. 1050 " |\n"
  1051. 1051 report = report +
  1052. 1052 "| 按钮状元素 | " +
  1053. 1053 (if result.ui_detection.has_button_like_elements {
  1054. 1054○ "检测到"
  1055. 1055 } else {
  1056. 1056● "未检测到"
  1057. 1057 }) +
  1058. 1058 " |\n"
  1059. 1059 report = report +
  1060. 1060 "| UI 元素总数 | " +
  1061. 1061● result.ui_detection.ui_element_count.to_string() +
  1062. 1062 " |\n"
  1063. 1063 report = report +
  1064. 1064 "| 水平线条数 | " +
  1065. 1065● result.ui_detection.horizontal_line_count.to_string() +
  1066. 1066 " |\n"
  1067. 1067 report = report +
  1068. 1068 "| 垂直线条数 | " +
  1069. 1069● result.ui_detection.vertical_line_count.to_string() +
  1070. 1070 " |\n"
  1071. 1071 report = report +
  1072. 1072 "| UI 区域比例 | " +
  1073. 1073● (result.ui_detection.ui_area_ratio * 100.0).to_string() +
  1074. 1074 "% |\n\n"
  1075. 1075
  1076. 1076 report = report + "### 文字检测详情\n\n"
  1077. 1077 report = report + "| 指标 | 值 |\n|------|------|\n"
  1078. 1078 report = report +
  1079. 1079 "| 文字区域数 | " +
  1080. 1080● result.text_detection.text_area_count.to_string() +
  1081. 1081 " |\n"
  1082. 1082 report = report +
  1083. 1083 "| 文字区域比例 | " +
  1084. 1084● (result.text_detection.text_area_ratio * 100.0).to_string() +
  1085. 1085 "% |\n"
  1086. 1086 report = report +
  1087. 1087 "| 小边缘密度 | " +
  1088. 1088● (result.text_detection.small_edge_density * 100.0).to_string() +
  1089. 1089 "% |\n\n"
  1090. 1090
  1091. 1091 report = report + "### 几何分析详情\n\n"
  1092. 1092 report = report + "| 指标 | 值 |\n|------|------|\n"
  1093. 1093 report = report +
  1094. 1094 "| 水平边缘比例 | " +
  1095. 1095● (result.geometry_analysis.horizontal_edge_ratio * 100.0).to_string() +
  1096. 1096 "% |\n"
  1097. 1097 report = report +
  1098. 1098 "| 垂直边缘比例 | " +
  1099. 1099● (result.geometry_analysis.vertical_edge_ratio * 100.0).to_string() +
  1100. 1100 "% |\n"
  1101. 1101 report = report +
  1102. 1102 "| 对角边缘比例 | " +
  1103. 1103● (result.geometry_analysis.diagonal_edge_ratio * 100.0).to_string() +
  1104. 1104 "% |\n"
  1105. 1105 report = report +
  1106. 1106 "| 几何规则性 | " +
  1107. 1107● (result.geometry_analysis.geometry_regularity * 100.0).to_string() +
  1108. 1108 "% |\n\n"
  1109. 1109
  1110. 1110 report = report + "### 颜色量化详情\n\n"
  1111. 1111 report = report + "| 指标 | 值 |\n|------|------|\n"
  1112. 1112 report = report +
  1113. 1113 "| 唯一颜色数(64级) | " +
  1114. 1114● result.color_quantization.unique_color_count.to_string() +
  1115. 1115 " |\n"
  1116. 1116 report = report +
  1117. 1117 "| 顶部颜色比例 | " +
  1118. 1118● (result.color_quantization.top_color_ratio * 100.0).to_string() +
  1119. 1119 "% |\n"
  1120. 1120 report = report +
  1121. 1121 "| 前10颜色比例 | " +
  1122. 1122● (result.color_quantization.top_10_color_ratio * 100.0).to_string() +
  1123. 1123 "% |\n"
  1124. 1124 report = report +
  1125. 1125 "| 调色板大小 | " +
  1126. 1126● result.color_quantization.color_palette_size.to_string() +
  1127. 1127 " |\n\n"
  1128. 1128
  1129. 1129 report = report + "### 说明\n\n"
  1130. 1130 report = report +
  1131. 1131 "- 本鉴定基于基础统计特征 + 增强特征(UI/文字/几何/颜色)综合分析\n"
  1132. 1132 report = report +
  1133. 1133 "- 增强特征专门针对屏幕截图/数字渲染图进行优化\n"
  1134. 1134 report = report +
  1135. 1135 "- 物理生成指示值越高,表示越可能是真实拍摄或屏幕截图\n"
  1136. 1136 report = report + "- 置信度表示鉴定结果的可靠程度\n"
  1137. 1137 report = report +
  1138. 1138 "- 对于经过编辑、压缩或重采样的图像,鉴定准确率可能下降\n"
  1139. 1139
  1140. 1140 report
  1141. 1141}