Can't get the issue with rows/columns images vs matrices in the first video of Computational Thinking

I can’t get the issue of Alan Edelman across all the first video of Introduction to Computational Thinking with the convention used for images vs matrices… the first index is the row index and the second one is the column index, where is the difference ?

Can you provide the video with the exact minute where he talks about this?

26.34 (when he says “images are a little bit different from matrices, 864 is the long way…”)
30.25 (when he says “is it going the other ways because it is images”)

When you specify a matrix, let’s say with m rows and n columns, you specify its size by the tuple (m, n).

For images, think about the resolution of your monitor. If you have an HD monitor, the resolution is probably 1920x1080 pixels. As you can see, the 1920 pixels hast to correspond to the width of the monitor (or the number of columns) and 1080 to its height.

This convention also apply to images. Therefore, for an image of size (800, 600), 800 corresponds to the number of columns and 600 to the number of rows. But many packages in Julia have the functionality to obscure this fact and you can index into the image as you would if you had a matrix.

Conventionally, it’s rows by columns:

Here’s the Images.jl documentation:

ok, I think I got it… Alan got confused because while in general images use (col,rows) order (so this is what he expected), the Julia package Images.jl uses the matrix convention of (rows,cols)…

There are lots of conventions:

width ▶️ height
x ▶️ y
rows ▶️ columns
latitude ▶️ longitude
needle ▶️ haystack

but occasionally they don’t convert easily.

Well, lat/long are often confused. Then there’s spherical coordinates… :scream_cat:


It should never be lat/long but always long/lat (i.e. x/y and not y/x). Not everybody seems to agree on this though :cry:

Looks like a lost cause - lon lat lon lat lon - :frowning:

Yes, but when using GDAL we have a safety valve. Always use OAMS_TRADITIONAL_GIS_ORDER
More on this lon/lat OGR Coordinate Reference Systems and Coordinate Transformation tutorial — GDAL documentation