liveBook · Manning

Rectangular-to-quadrilateral transformation

As explained in Geometry for Programmers

A quadrilateral-to-rectangular transformation is a projective mapping from a quadrilateral image region to a rectangular output domain.

A rectangular-to-quadrilateral transformation maps each pixel in a flat rectangular output to its corresponding location in a photographed quadrilateral. This reverses the direction suggested by perspective correction: the scan asks where every target pixel came from. section 4.4.1

The practical construction uses a unit square as an intermediate domain. Scaling maps the rectangle to that square; a four-point projective transformation then maps the square to the source image. Choosing square corners simplifies the large symbolic system into smaller successive solves. section 4.4.1

Scanning a photographed page

Given four image points corresponding to the corners of a rectangular page, map target pixels through the unit square and into the camera image to undo natural perspective. section 4.4.1

How Geometry for Programmers covers it

How deep it goes
Derives a staged symbolic solve using unit-square coordinates, rather than leaving the arbitrary four-point system intact.
Examples
Uses phone-based document scanning, photographed page corners, target pixels, and a unit square.
What it assumes
Assumes familiarity with arbitrary four-point transformations and coordinates while introducing the unit-square simplification.
What you can do after
Evaluate/understand how to decompose a rectangular-to-quadrilateral mapping into scaling and four-point solving.
How it connects
Connects projective transformation, perspective correction, scaling, and four-point transformation.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Geometry for Programmers. The section links point to the parts of the book it draws on.