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

**URL:** <https://discourse.julialang.org/t/cant-get-the-issue-with-rows-columns-images-vs-matrices-in-the-first-video-of-computational-thinking/87301>\
**Category:** Teaching & Outreach\
**Tags:** computationalthinkin\
**Created:** [September 15, 2022, 7:45am UTC](https://discourse.julialang.org/t/cant-get-the-issue-with-rows-columns-images-vs-matrices-in-the-first-video-of-computational-thinking/87301 "2022-09-15T07:45:20Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [September 15, 2022, 7:45am UTC](https://discourse.julialang.org/t/cant-get-the-issue-with-rows-columns-images-vs-matrices-in-the-first-video-of-computational-thinking/87301/1 "2022-09-15T07:45:20Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![RayleighLord](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rayleighlord/32/33592_2.png) [@RayleighLord](https://discourse.julialang.org/u/RayleighLord)\
**Post date:** [September 15, 2022, 7:47am UTC](https://discourse.julialang.org/t/cant-get-the-issue-with-rows-columns-images-vs-matrices-in-the-first-video-of-computational-thinking/87301/2 "2022-09-15T07:47:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [September 15, 2022, 8:04am UTC](https://discourse.julialang.org/t/cant-get-the-issue-with-rows-columns-images-vs-matrices-in-the-first-video-of-computational-thinking/87301/3 "2022-09-15T08:04:46Z")

</div>

[![](https://global.discourse-cdn.com/julialang/original/3X/1/d/1dabda29542e3a5d9cbc8471ab5951f04d71ce8a.jpeg "Course Welcome + Intro to Arrays & Images! MIT Computational Thinking Spring 2021 | Lecture 1") ](https://www.youtube.com/watch?v=3zTO3LEY-cM)

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”)

---

<div class="post-metadata">

**Author:** ![RayleighLord](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rayleighlord/32/33592_2.png) [@RayleighLord](https://discourse.julialang.org/u/RayleighLord)\
**Post date:** [September 15, 2022, 9:25am UTC](https://discourse.julialang.org/t/cant-get-the-issue-with-rows-columns-images-vs-matrices-in-the-first-video-of-computational-thinking/87301/4 "2022-09-15T09:25:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [September 15, 2022, 9:33am UTC](https://discourse.julialang.org/t/cant-get-the-issue-with-rows-columns-images-vs-matrices-in-the-first-video-of-computational-thinking/87301/5 "2022-09-15T09:33:39Z")

</div>

Conventionally, it’s `rows` by `columns`:

Here’s the Images.jl documentation:

 ![Screenshot 2022-09-15 at 10.32.02](https://global.discourse-cdn.com/julialang/original/3X/3/c/3cde12c6613da7b63e998b53e21fa3c1e25b5ddd.png)

---

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [September 15, 2022, 11:43am UTC](https://discourse.julialang.org/t/cant-get-the-issue-with-rows-columns-images-vs-matrices-in-the-first-video-of-computational-thinking/87301/6 "2022-09-15T11:43:57Z")

</div>

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)…

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [September 15, 2022, 11:56am UTC](https://discourse.julialang.org/t/cant-get-the-issue-with-rows-columns-images-vs-matrices-in-the-first-video-of-computational-thinking/87301/7 "2022-09-15T11:56:30Z")

</div>

There are lots of conventions:

```julia
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… 🙀

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [September 15, 2022, 12:48pm UTC](https://discourse.julialang.org/t/cant-get-the-issue-with-rows-columns-images-vs-matrices-in-the-first-video-of-computational-thinking/87301/8 "2022-09-15T12:48:05Z")

</div>

> [@cormullion](#):
>
> Well, lat/long are often confused.

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 😢

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [September 15, 2022, 3:30pm UTC](https://discourse.julialang.org/t/cant-get-the-issue-with-rows-columns-images-vs-matrices-in-the-first-video-of-computational-thinking/87301/9 "2022-09-15T15:30:29Z")

</div>

Looks like a lost cause - [lon lat lon lat lon - macwright.com](https://macwright.com/lonlat/index.html) ☹

---

<div class="post-metadata">

**Author:** ![joa-quim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joa-quim/32/227_2.png) [@joa-quim](https://discourse.julialang.org/u/joa-quim)\
**Post date:** [September 15, 2022, 5:03pm UTC](https://discourse.julialang.org/t/cant-get-the-issue-with-rows-columns-images-vs-matrices-in-the-first-video-of-computational-thinking/87301/10 "2022-09-15T17:03:17Z")

</div>

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](https://gdal.org/tutorials/osr_api_tut.html#crs-and-axis-order)
