# Function imgradients does not accept keyword arguments

**URL:** <https://discourse.julialang.org/t/function-imgradients-does-not-accept-keyword-arguments/14019>\
**Category:** General Usage\
**Tags:** images\
**Created:** [August 24, 2018, 11:58pm UTC](https://discourse.julialang.org/t/function-imgradients-does-not-accept-keyword-arguments/14019 "2018-08-24T23:58:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![microlifecc](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@microlifecc](https://discourse.julialang.org/u/microlifecc)\
**Post date:** [August 24, 2018, 11:58pm UTC](https://discourse.julialang.org/t/function-imgradients-does-not-accept-keyword-arguments/14019/1 "2018-08-24T23:58:18Z")

</div>

Hi!  
I am trying to get the gradient magnitude for each pixel of the image as [here](https://juliaimages.github.io/latest/function_reference.html#ImageFiltering.imgradients):

` imgradients(imgF, kernelfun=KernelFactors.ando3, border="replicate")`

I am getting this error:

> function imgradients does not accept keyword arguments  
> Stacktrace:  
> [1] kwfunc(::Any) at ./boot.jl:237

Also is there a way to get the gradient direction similar to that in MATLAB as [here](https://www.mathworks.com/help/images/ref/imgradient.html).

Any help plz? Thanks!

---

<div class="post-metadata">

**Author:** ![stillyslalom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stillyslalom/32/45687_2.png) [@stillyslalom](https://discourse.julialang.org/u/stillyslalom)\
**Post date:** [August 25, 2018, 1:53am UTC](https://discourse.julialang.org/t/function-imgradients-does-not-accept-keyword-arguments/14019/2 "2018-08-25T01:53:36Z")

</div>

Keyword arguments are given following a semicolon in the type signature–`kernelfun` and `border` are regular arguments with the default values `ando3` and `"replicate"`. If the documentation was accurate, calling `imgradients(img)` would be equivalent to calling `ingredients(img, KernelFactors.ando3, "replicate")`. However, the single-argument method seems to be missing:

```julia
julia> methods(imgradients)
# 2 methods for generic function "imgradients":
[1] imgradients(img::AbstractArray, kernelfun::Function) in ImageFiltering at /Users/alexames/.julia/packages/ImageFiltering/4wAwj/src/specialty.jl:501
[2] imgradients(img::AbstractArray, kernelfun::Function, border) in ImageFiltering at /Users/alexames/.julia/packages/ImageFiltering/4wAwj/src/specialty.jl:501

```

What you’re looking for is `imedge`:

```julia
using FileIO

coins = Gray.(load("https://www.mathworks.com/help/images/ref/imgca1.gif"))
gy, gx, mag, ϕ = imedge(coins)

Gray.([imadjustintensity(mag) imadjustintensity(ϕ)])

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/5/5/553b36f2ea4e39fc085e731513b6bca0a215953c.jpeg)

---

<div class="post-metadata">

**Author:** ![microlifecc](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@microlifecc](https://discourse.julialang.org/u/microlifecc)\
**Post date:** [August 25, 2018, 2:25am UTC](https://discourse.julialang.org/t/function-imgradients-does-not-accept-keyword-arguments/14019/3 "2018-08-25T02:25:18Z")

</div>

Thanks a ton @stillyslalom!
