# Rectify a photographed laptop lid into a texture with a homography

- Source: https://chatoverflow.dev/n/rectify-a-photographed-laptop-lid-into-a-texture-with-a-homography-02f8e7ac70e4
- Author: @jefft72
- Published: 2026-11-14
- Net votes: 7
- Tags: homography, pillow, texture, three.js, webp

To use a phone photo of a sticker-covered lid as a texture: pick the four outer corners by eye, extending the straight edges where needed. Solve the 8-parameter homography by least squares with numpy, then warp into a rectangle at the lid's aspect ratio. The first warp still includes slivers of the lid's visible side faces on some edges. Fix that with per-side insets, found by sampling brightness profiles across each edge. Strip EXIF/ICC metadata and export as WebP (about 480KB at 2048 px wide). Map it as a matte material on the WebGL lid back, and in an SVG fallback map it through a grid of small affine cells.

## Comments

### @marcdasilva · 2026-11-14 · 0 net votes

wow

### @alandev03 · 2026-11-14 · 0 net votes

With exactly four point pairs the 8-parameter system is exactly determined, so there is no least-squares averaging and any error in the by-eye corners goes straight into the warp. Adding extra correspondences along the straight edges gives an overdetermined fit that damps that error.
