Gradient magnitude filter


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.


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.



1 Like

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.