Card Analysis Calculations

🔧Perspective Correction via Homography

When you photograph a flat object like a trading card from an angle, the image undergoes a projective transformation, also known as a homography. This distortion makes rectangles appear as general quadrilaterals (often like parallelograms or trapezoids).

To get accurate centering measurements, we compute the homography matrix that maps the card's outer corners to a perfect rectangle (e.g., a standard 750×1050 canvas). We then apply this same transform to the inner content corners, effectively "un-distorting" the card to a top-down view before measuring anything.

This ensures that all margin measurements reflect the card's true physical proportions, regardless of the angle the photo was taken from.

🧮 How Centering is Calculated

When you place the 8 keypoints (4 outer corners of the card, 4 inner corners of the content box), here's what happens:

  1. Homography Matrix: We compute a homography matrix that maps the 4 outer card corners to a perfect rectangle (the card's known aspect ratio).
    H = getHomographyMatrix(outerCorners, targetRectangle)
  2. Transform Inner Corners: We apply the same matrix to the 4 inner content corners, projecting them into the corrected, top-down space.
    correctedInnerCorners = applyHomography(H, innerCorners)
  3. Margin Measurement: In corrected space, the outer edges are straight lines at known positions. We measure margins from those edges to the corrected inner corners:
    left_margin = correctedInnerLeft - targetLeft
    right_margin = targetRight - correctedInnerRight
    top_margin = correctedInnerTop - targetTop
    bottom_margin = targetBottom - correctedInnerBottom
  4. Ratio Calculation: Centering ratios are computed from these perspective-corrected margins.
    left_centering_ratio = left_margin / (left_margin + right_margin)
    top_centering_ratio = top_margin / (top_margin + bottom_margin)
  5. Balance Score: A balance score is calculated using the ratio of the smaller margin to the larger margin:
    leftRight_balance = (min(left, right) / max(left, right)) × 100
    topBottom_balance = (min(top, bottom) / max(top, bottom)) × 100
    This ratio-based approach aligns with industry standards and provides more intuitive scoring.

By correcting for perspective first, these measurements reflect the card's true physical centering — not just how it appears from the camera angle. This produces consistent results regardless of how the photo was taken.

📏 Ratio-Based Centering Scoring

Our centering scores use a ratio-based approach that aligns with professional card grading standards used by PSA, BGS, and other major grading companies.

Why Ratio-Based Scoring?

  • Industry Standard: Matches how professional graders evaluate centering
  • Intuitive Results: Perfect centering = 100%, proportionally decreases with imbalance
  • No Arbitrary Penalties: Scoring directly reflects the physical relationship between borders
  • Consistent Scaling: A 60/40 split always scores the same regardless of card size

Example Results:

50/50 split → 50/50 = 100% ✅
45/55 split → 45/55 = 81.8%
40/60 split → 40/60 = 66.7%
30/70 split → 30/70 = 42.9%
20/80 split → 20/80 = 25.0%

Grading Expectations:

  • 90-100%: Excellent centering
  • 75-89%: Good centering
  • 60-74%: Fair centering
  • Below 60%: Poor centering

🟣 Why Perspective Correction Matters

This tool applies perspective correction (homography) to every measurement. By mathematically "un-distorting" the card corners back into a perfect rectangle, we get:

  1. Angle-Independent Results: The same card photographed from different angles produces consistent centering scores.
  2. True Physical Proportions: Measurements reflect the card's actual border widths, not distorted image-space distances.
  3. Cross-Photo Comparability: You can compare centering between cards photographed under different conditions.

If the homography computation fails (e.g., due to degenerate corner placement), the tool falls back to a direct ratio method that measures centering in raw image space — still useful, but less accurate for heavily angled photos.

TL;DR

  • Homography-Based Correction (Primary): Computes a homography matrix from the 4 outer card corners, transforms the inner corners into corrected space, and measures margins against a perfect rectangle. Produces angle-independent, physically accurate centering scores.
  • Direct Ratio Fallback: If the homography computation fails, centering is calculated from ratios measured directly in image space. Still useful, but less accurate for angled photos.