# Image gradients and resampling

**URL:** <https://discourse.itk.org/t/image-gradients-and-resampling/898>\
**Category:** Algorithms\
**Created:** [May 3, 2018, 7:33pm UTC](https://discourse.itk.org/t/image-gradients-and-resampling/898 "2018-05-03T19:33:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![beastwood](https://discourse.itk.org/letter_avatar_proxy/v4/letter/b/ad7895/32.png) [@beastwood](https://discourse.itk.org/u/beastwood)\
**Post date:** [May 3, 2018, 7:33pm UTC](https://discourse.itk.org/t/image-gradients-and-resampling/898/1 "2018-05-03T19:33:05Z")

</div>

Hi All,

I’m hoping someone can explain to some behavior I didn’t expect.

I am computing the gradient magnitude of a 3D image along the first two dimensions by using a collection of itk::RecursiveGaussianImageFilters, with all sigmas specified in physical units.

If I downsample the image by a factor of 2 along the first two dimensions using itk::ResampleImageFilter and use the same physical sigmas for gradient magnitude computation, the resulting intensities are twice that of the gradient magnitude computed without downsampling. If I downsample by a factor of 4, the intensities increase four-fold. This occurs whether or not NormalizeAcrossScale is enabled on the Gaussian filters. Why is that? I did not expect derivative estimates computed with physical spacing to be drastically different just based on downsampling.

Replacing the itk::RecursiveGaussianImageFilters with corresponding itk::DiscreteGaussianDerivativeImageFilters (configured a little differently) and enabling NormalizeAcrossScale produces gradient magnitudes that are the same scale with and without downsampling, matching what I expected. (These filters are much slower in this application, however.)

What am I not understanding about the recursive Gaussian filters?

Thank you,  
Brian Eastwood
