# Images.imedge: grad, phase and orientation

**URL:** <https://discourse.julialang.org/t/images-imedge-grad-phase-and-orientation/33955>\
**Category:** New to Julia\
**Tags:** question, images\
**Created:** [January 30, 2020, 12:51am UTC](https://discourse.julialang.org/t/images-imedge-grad-phase-and-orientation/33955 "2020-01-30T00:51:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ameba\_Brain](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ameba_brain/32/10874_2.png) [@Ameba\_Brain](https://discourse.julialang.org/u/Ameba_Brain)\
**Post date:** [January 30, 2020, 12:51am UTC](https://discourse.julialang.org/t/images-imedge-grad-phase-and-orientation/33955/1 "2020-01-30T00:51:58Z")

</div>

[Images.imedge](https://github.com/JuliaImages/Images.jl/blob/master/src/edge.jl#L107) function implementation calculates gradients as `grad_y, grad_x = imgradients(img, kernelfun, border)`

But right in the next line it passes `grad_y, grad_x` into the `magnitude` and `orientation` methods which have parameter list specifed as `grad_x, grad_y`

```julia
mag = magnitude(grad_y, grad_x)
orient = orientation(grad_y, grad_x)

```

While it’s not a problem for `magnitude` method which calcs `Base.hypot` but for `orientation` I believe it has direct impact because inside it there is a `atan(grad_x, grad_y)` is calculated

It this a bug or not?

More general question.

In `orientation` method specification it’s said

> Calculate the orientation angle of the strongest edge from gradient images

`phase` method

> Calculate the rotation angle of the gradient

What does exactly this mean? In geometry terms

As I understand we can calculate angle between ray ( unit vector from coordinate system center to the given point ) and positive ( negative? ) direction of either axis Y or X. Which axis is taken? Which has more absolute value? It’s not clear from code implementation

---

<div class="post-metadata">

**Author:** ![pxshen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pxshen/32/38776_2.png) [@pxshen](https://discourse.julialang.org/u/pxshen)\
**Post date:** [November 27, 2022, 7:57pm UTC](https://discourse.julialang.org/t/images-imedge-grad-phase-and-orientation/33955/2 "2022-11-27T19:57:54Z")

</div>

You can calculate image gradients using [EquivariantOperators.Del](https://aced-differentiate.github.io/EquivariantOperators.jl/guide/#Del) which is partially built on top of `Images` but has resolution parameters for automatic scaling.
