# Gradient magnitude filter

**URL:** <https://discourse.itk.org/t/gradient-magnitude-filter/603>\
**Category:** Algorithms\
**Created:** [January 18, 2018, 10:03pm UTC](https://discourse.itk.org/t/gradient-magnitude-filter/603 "2018-01-18T22:03:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fijoy\_Vadakkumpadan](https://discourse.itk.org/user_avatar/discourse.itk.org/fijoy_vadakkumpadan/32/1287_2.png) [@Fijoy\_Vadakkumpadan](https://discourse.itk.org/u/Fijoy_Vadakkumpadan)\
**Post date:** [January 18, 2018, 10:03pm UTC](https://discourse.itk.org/t/gradient-magnitude-filter/603/1 "2018-01-18T22:03:55Z")

</div>

Hello,

Is there any difference between the gradients calculated by GradientMagnitudeImageFilter and GradientImageFilter?

I took a quick look at the source expecting the former filter to call the latter + AbsImageFilter, but that was not the case. It looked like both filters are directly using the first order derivative operator, so wondering.

Thanks,  
–Fijoy

---

<div class="post-metadata">

**Author:** ![tim-evain](https://discourse.itk.org/user_avatar/discourse.itk.org/tim-evain/32/220_2.png) [@tim-evain](https://discourse.itk.org/u/tim-evain)\
**Post date:** [January 19, 2018, 8:51am UTC](https://discourse.itk.org/t/gradient-magnitude-filter/603/2 "2018-01-19T08:51:30Z")

</div>

Hi Fijoy,

The main difference is that you get only the magnitude of the gradient at each voxel with the former, whereas the latter have the full vector, so you can also have the direction of the gradient.

HTH,

Tim

---

<div class="post-metadata">

**Author:** ![Fijoy\_Vadakkumpadan](https://discourse.itk.org/user_avatar/discourse.itk.org/fijoy_vadakkumpadan/32/1287_2.png) [@Fijoy\_Vadakkumpadan](https://discourse.itk.org/u/Fijoy_Vadakkumpadan)\
**Post date:** [January 19, 2018, 9:11pm UTC](https://discourse.itk.org/t/gradient-magnitude-filter/603/3 "2018-01-19T21:11:15Z")

</div>

Hi Tim,

I expected the GradientMagnitudeImageFilter to use the GradientImageFilter to calculated gradients and then simply calculate the magnitudes of the resulting vectors. I didn’t see that in the code, so wondered if there were any differences in the way gradients were calculated in the 2 filters. It sounds like there is none. Thanks.

–Fijoy
