Skip to content

Instantly share code, notes, and snippets.

@Evgenij-Gr
Evgenij-Gr / Mapping from plane coordinates to image pixels
Last active August 29, 2015 13:57
Suppose that we have an image on the plane, which borders are parallel to coordinate axis. This procedure does the mapping from plane coordinates to pixels of image.
#! /usr/bin/python
# We lay sides of image parallel to axi of planes
# Bigger side of image maps to bigger side of rect
# On images we always have X ~ Width, Y ~ Height (it is true for OpenCV)
def PlaneToImage(Point, LTCorner, RBCorner, resW, resH):
assert(not resW==resH)
if (resW > resH):
if (abs(LTCorner[0]-RBCorner[0]) > abs(LTCorner[1]-RBCorner[1])):
OnImgX, OnImgY = 0, 1