https://github.com/bchao1/homography

2D projection geometry with homography.

https://github.com/bchao1/homography

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (9.3%) to scientific vocabulary

Keywords

computer-graphics computer-vision homography image-processing projection-geometry
Last synced: 5 months ago · JSON representation

Repository

2D projection geometry with homography.

Basic Info
  • Host: GitHub
  • Owner: bchao1
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 3.47 MB
Statistics
  • Stars: 2
  • Watchers: 2
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Topics
computer-graphics computer-vision homography image-processing projection-geometry
Created over 5 years ago · Last pushed over 5 years ago
Metadata Files
Readme

README.md

homography

The meme square with projection geometry.

img

Usage

The main algorithm is in homography/main.py. To process the images, you need to specify custom parameters in homography/config.yaml file: - canvas_image: file path of the background canvas image - project_images: list of file paths of the images to project onto the canvas - output_image: file path of the output image - coors: a list of quadrilateral corners in canvas coordinates. Should be same length as project_images. Note that in the config file, x is defined as the vertical axis, while y is the horizontal axis.

This pixel is (x, y) = (5, 2). __ __ __ __ __ __ __ y (width) |__|__|__|__|__|__ |__|__|__|__|__|__ |__|__|__|__|__|__ |__|__|__|__|__|__ |__|██|__|__|__|__ |__|__|__|__|__|__ | x (height)

Referring to homography/config.yaml, the four corners of image 1.jpg, starting from top-left in clockwise order, will be projected to the first entry of coors, which are four canvas coordinates: yaml coors: - top_left: x: 296.3452162756598 y: 795.149285190616 top_right: x: 49.88489736070392 y: 1194.9957844574778 bottom_right: x: 346.23295454545456 y: 1197.9741568914956 bottom_left: x: 460.90029325513194 y: 799.6168438416423

After modifying config.yaml, simply run: python3 main.py in homography/. You can also try out the demo config.yaml provided, using images in data/.

How this works

Homography

Projecting a 2D image onto another image (the "canvas") involves computing the tranformation between two homogeneous coordinate systems. We refer to the coordinate system of the image to project as the source coordinates, and the coordinate system of the canvas as the target coordinates.

Coordinate transforms

Suppose a point (u_x, u_y, 1) in the source coordinate is projected to a point in (v_x, v_y, 1) in target coordinates, we can represent the projection as a homography H, which is a 3*3 matrix.

Homography

Since H is invariant to scaling, we usually constrain h_33 = 1 so that H has 8 degree of freedom (DoF) rather than 9. Another way to enforce 8 DoF is constraining the squared sum of all elements in H to be 1 (which turns out to be a more robust constraint).

Solving H

To solve H, we need 8 equations since H has 8 DoF. This is equivalent to 4 pairs of mappings between source and target coordinates(4 points define a homography). We can simply choose the four corners of the source image and its expected transformed target coordinates to construct our equations.

For each homogeneous coordinate mapping (u_x, u_y, 1) -> (v_x, v_y, 1), we can write down two equations:

Equation 1

Writing in matrix multiplication form:

Equation 2

Since we have 4 pairs of coordinate mappings, we can stack all 2 * 9 matrices into a single 8 * 9 matrix A, and solve the homogeneous system: Ah = 0, subject to ||h|| = 1 We solve h by performing singular value decomposition on ATA. h would be the eigenvector corresponding to the smallest eigenvalue.

Owner

  • Name: Brian Chao
  • Login: bchao1
  • Kind: user
  • Location: Stanford, California
  • Company: Stanford University

Stanford Ph.D. student. Research in computational photography, displays, and computer graphics. Open source enthusiast.

GitHub Events

Total
Last Year

Committers

Last synced: 8 months ago

All Time
  • Total Commits: 11
  • Total Committers: 1
  • Avg Commits per committer: 11.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
bchao1 w****0@g****m 11

Issues and Pull Requests

Last synced: 8 months ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels