<p>I am trying to find gradient of the following image. Now shouldn't the gradient for <span class="math-container">$x$</span> be the vertical lines with respect to axes we have on the top left corner please?</p>
<p><a href="https://i.sstatic.net/GaRhn.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/GaRhn.png" alt="enter image description here" /></a></p>

CC BY-SA 4.0
2022-07-14T17:36:55.423Z
They adopted a convention where $y$ increases left to right and $x$ increases top to bottom so the images are labeled properly. It's not a typical convention,but they have specified it, so there isno issue.
lightxbulb
CC BY-SA 4.0
2022-07-15T00:34:09.133Z
@lightxbulb. So you mean when taking the derivative, $x$ is the horizontal one while $y$ is the vertical one? What about the convention please? I did not get it?
Avv
CC BY-SA 4.0
2022-07-15T18:38:07.757Z
If you had an imaginary cursor and you moved it top to bottom its $x$ coordinate would increase due to the $x$ basis vector pointing down. In the exact same way if you were to move that same cursor from left to right then its $y$ coordinate would increase.
lightxbulb
CC BY-SA 4.0
2022-07-18T22:58:45.687Z
@lightxbulb. Thank you. But when taking the derivative, we treat $x$ as horizontal while $y$ is vertical?
Avv
CC BY-SA 4.0
2022-07-19T06:02:17.567Z
$x$ is the vertical axis (increasing top to bottom) as indicated by the basis vector in the top right, while $y$ is the horizontal one (increasing left to right).
lightxbulb
CC BY-SA 4.0
2022-07-19T15:13:38.217Z
@lightxbulb. Thanks. But if that is the case, why the derivative  of $x$ in the image above are the horizontal red lines?
Avv
CC BY-SA 4.0
2022-07-19T17:23:00.167Z
Idk what the point of the red lines is tbh, it's just scribbles on top of the derivative images as far as I can tell. In practice you would compute those images using finite differences. For example if your image is `float img[w][h];` then the $x$ derivative image may be computed as `dx[x][y] = img[x][y] - img[x-1][y]` with special boundary handling amounting to `img[-1][y] = img[0][y]`. A similar approach with differences along the second index would yield the approximation of the $y$ derivative.
lightxbulb
<image-processing><gradient>
Image gradient of $x$-axis
Avv
# Image gradient of $x$-axis

(Asked by: username_0 on 2022-07-14)

I am trying to find gradient of the following image. Now shouldn't the gradient for $x$ be the vertical lines with respect to axes we have on the top left corner please?

[![enter image description here](https://i.sstatic.net/GaRhn.png)](https://i.sstatic.net/GaRhn.png)

**Tags:** image-processing, gradient

> **Comments:**
> **username_1**: They adopted a convention where $y$ increases left to right and $x$ increases top to bottom so the images are labeled properly. It's not a typical convention,but they have specified it, so there isno issue.  
> **username_0**: @username_1. So you mean when taking the derivative, $x$ is the horizontal one while $y$ is the vertical one? What about the convention please? I did not get it?  
> **username_1**: If you had an imaginary cursor and you moved it top to bottom its $x$ coordinate would increase due to the $x$ basis vector pointing down. In the exact same way if you were to move that same cursor from left to right then its $y$ coordinate would increase.  
> **username_0**: @username_1. Thank you. But when taking the derivative, we treat $x$ as horizontal while $y$ is vertical?  
> **username_1**: $x$ is the vertical axis (increasing top to bottom) as indicated by the basis vector in the top right, while $y$ is the horizontal one (increasing left to right).  
> **username_0**: @username_1. Thanks. But if that is the case, why the derivative  of $x$ in the image above are the horizontal red lines?  
> **username_1**: Idk what the point of the red lines is tbh, it's just scribbles on top of the derivative images as far as I can tell. In practice you would compute those images using finite differences. For example if your image is `float img[w][h];` then the $x$ derivative image may be computed as `dx[x][y] = img[x][y] - img[x-1][y]` with special boundary handling amounting to `img[-1][y] = img[0][y]`. A similar approach with differences along the second index would yield the approximation of the $y$ derivative.  

---

## 0 answers

