MCPcopy Create free account
hub / github.com/32comic/image2pixel-web / findCommonSizes

Method findCommonSizes

pixelizer.js:377–397  ·  view source on GitHub ↗
(horizontal, vertical)

Source from the content-addressed store, hash-verified

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 };

Callers 1

detectPixelBlockSizeMethod · 0.95

Calls 1

gcdMethod · 0.95

Tested by

no test coverage detected