Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

Coordinate systems and functions as mappings

~12 min

linear-algebra's readiness chapter framed a function as a rule from one set (the domain) to another (the codomain). It is not just "a formula you plug numbers into." This course leans on that framing right away: a digital image is a function. The way it is laid out has one twist worth naming now, before it trips you up later.

Quick review

Practice from earlier coursework, pulled in for this topic.

From Linear Algebra — Vectors, Matrices, and the Geometry of Data

What is the domain of g(x) = \sqrt{x-6}?

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

Flip the inequality — a square root needs its radicand to be at least zero, so x-6\ge0 gives x\ge6, not x\le6.

x=6 itself is allowed since \sqrt{0}=0 is defined — the boundary point belongs in the domain, so the inequality isn't strict.

A square root does restrict the domain — negative radicands aren't real numbers, so not every x works.

Why

A square root is only real-valued when its radicand is non-negative. Solving x-6\ge0 gives x\ge6.

From Linear Algebra — Vectors, Matrices, and the Geometry of Data

Let f(x)=3x-2 and g(x)=x^2. Find (f\circ g)(2).

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

Why

Apply g first: g(2)=2^2=4. Then apply f to that result: f(4)=3(4)-2=10.

Correct answer

Also accepted:

Why

A function is just a rule. Put something in, and one specific thing always comes out. Feed it the same input twice and you always get the same output back. That is the whole definition, no more mysterious than a vending machine: press B4, always get the same snack. An image is a function of this exact kind. Feed it a pixel location, and it hands back that pixel's brightness, every time, for that one image.

The one genuinely tricky part is which way "up" points. On an ordinary math graph, y grows as you move up the page. On every image this course will show you, y grows as you move down the page. Row 0 is the top row, and row 99 (say) sits further down, not further up. This is not a mistake anyone made. It is just how a screen or a printed photo gets built: one row at a time, starting from the top. That is the same way you would read a page of text, starting at the top-left. The fix is simple. Whenever this course writes (x, y) for a pixel, picture x as "how far right" and y as "how far down," never "how far up."

A function f: X \to Y assigns to each element of a domain X exactly one element of a codomain Y. A digital image of height H and width W is a function I : \{0, 1, \dots, H-1\} \times \{0, 1, \dots, W-1\} \to \{0, 1, \dots, 255\}, mapping a discrete grid of coordinate pairs to an intensity value. That is exactly the "one set to another" reading above, with the domain restricted to whole numbers instead of all of \mathbb R.

This course fixes one coordinate convention throughout, and it is not the one ordinary xy-graphing uses. Image coordinates are written (x, y), where x increases rightward as usual but y increases downward, starting from 0 at the top row. That is the opposite of a Cartesian graph, where the y-axis points up. Equivalently, when an image is indexed as a matrix (Section 1), the row number plays the role of y and the column number plays the role of x. So I(x, y) = I[\text{row}=y, \text{col}=x]. This flip exists because a raster image is stored and displayed top row first. It matches how the hardware and every image library actually lay pixels out in memory, not a mathematical preference.

An image, read as a function

Send in a few (x, y) coordinate pairs and watch what the image function I(x, y) hands back -- a brightness value, not a location.

Loading interactive…

Worked example

Converting between row-column and x-y notation

  1. 1

    A grayscale image is stored as a matrix I with 6 rows and 8 columns. What is I[3, 5] in terms of (x, y) coordinates, and what is I(5, 3) in terms of row/column indices? By this course's convention, row plays the role of y and column plays the role of x.

  2. 2

    I[3, 5] has row =3, column =5, so it corresponds to (x, y) = (5, 3): 5 pixels right of the left edge, 3 pixels down from the top. I[3, 5] = I(5, 3)

  3. 3

    Reading it the other direction, I(5, 3) means x=5, y=3, which is row 3, column 5, the identical entry as I[3, 5]. The two notations name the same number; only the order of the two coordinates swaps.

Loading interactive…

Worked example

Which way does the image move?

  1. 1

    Starting at pixel (x,y)=(1,1) in the widget above, which direction does increasing y to (1,2) move -- toward the top of the image or the bottom? Larger y means further down, by this course's convention, never further up.

  2. 2

    Moving from (1,1) to (1,2) moves one row further down the image -- from row 1 to row 2 -- staying in the same column.

Loading interactive…

Where this goes next

Computer vision and robotics libraries

Every major image library (NumPy arrays, OpenCV, MATLAB) indexes an image as (row, col), matrix order. But it reports pixel locations to a user, say from a mouse click or a detected object's box, as (x, y), the flipped order this section names. A robotics or computer-vision system that mixes the two up without converting makes one of the most common real bugs in the field. An object correctly found at row 50, column 120 gets reported as "x=50, y=120" instead of "x=120, y=50." That silently turns every later coordinate by 90 degrees. Naming the convention once, clearly, here, is exactly what prevents that.

Check your understanding (counts toward your progress)

Why does image y increase downward instead of upward?

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

There's a concrete hardware/display reason, not an unmotivated accident.

Nothing about the underlying arithmetic changes based on which way y points -- this isn't a math-simplicity choice.

Printed math graphs conventionally have y increasing UPWARD -- this is exactly the opposite convention image coordinates use.

Why

A raster image is stored and rendered row by row starting from the top, so row 0 (the smallest index) is the top row -- the display hardware's own layout drives the convention, not a mathematical preference.

On a 10\times 10 image, the pixel I[6, 3] (row 6, column 3) corresponds to which x-coordinate under this course's convention?

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

Why

Column plays the role of x, so I[6, 3]'s column, 3, is its x-coordinate.

Correct answer

Also accepted:

Why

This course writes an image as a function I(x, y). What does I hand back for a given (x, y)?

Correct! 🎉 Not quite.

Right on try — credit. Right — the answer had already been shown, so no credit this time. Next try is worth Answer shown after three tries — this one no longer earns credit. You chose to see the answer — this one earns no credit.

(x, y) IS the input coordinate pair going in -- the function's job is to hand back the value stored there, not echo the coordinates back.

Width and height describe the whole image, not one particular input/output pair of the function.

An image function's codomain is intensity values, not more coordinates.

Why

I(x,y) is defined to map a pixel coordinate to that pixel's stored brightness value.

Explain, in your own words, why an image can be described as a function even though it's usually thought of as a picture, not a formula.

Practice: Row/column vs. x/y (3 problems · doesn’t affect your progress)

Given I[7, 2] on a 10\times 10 image, state the (x, y) coordinate.

Given the pixel location (x, y) = (9, 1), state the row/column index.

A bug report says "the top of the image looks like it should be the bottom." What's the most likely coordinate mistake behind it?

Which axis did this section warn increases in the opposite direction from an ordinary math graph?

Feeling good about this section?

Take the section quiz

Every answer gets a full explanation at the end.

Graph settings

Calculator

Sign in to save highlights

Insert an equation

  • No matches.