(horizontal, vertical)
| 375 | } |
| 376 | |
| 377 | findCommonSizes(horizontal, vertical) { |
| 378 | const candidates = []; |
| 379 | |
| 380 | // 基于众数的候选 |
| 381 | if (horizontal.mode === vertical.mode && horizontal.mode > 1) { |
| 382 | candidates.push({ size: horizontal.mode, confidence: 0.9 }); |
| 383 | } |
| 384 | |
| 385 | // 基于GCD的候选 |
| 386 | const commonGcd = this.gcd(horizontal.gcd, vertical.gcd); |
| 387 | if (commonGcd > 1 && commonGcd <= 16) { |
| 388 | candidates.push({ size: commonGcd, confidence: 0.7 }); |
| 389 | } |
| 390 | |
| 391 | // 如果没有好的候选,返回默认值 |
| 392 | if (candidates.length === 0) { |
| 393 | candidates.push({ size: 1, confidence: 0.1 }); |
| 394 | } |
| 395 | |
| 396 | return candidates.sort((a, b) => b.confidence - a.confidence); |
| 397 | } |
| 398 | |
| 399 | validateCandidates(imageData, candidates) { |
| 400 | let bestCandidate = { blockSize: 1, confidence: 0 }; |
no test coverage detected