Given that I have an image f(x,y) loaded, for example,
I want to compute the Gaussian derivative ∂/∂x ∂/∂y G*f of the image f, where G is a Gaussian filter and * denotes convolution. This is easily done using Scipy:
from scipy.ndimage.filters import gaussian_filter
imshow(gaussian_filter(g, sigma, order=1))
With sigma=50 this produces the following result:
Now, for applicationary reasons, I need to do the computation with mode='constant':
imshow(gaussian_filter(g, sigma, order=1, mode='constant', cval=0))
Still, the result looks reasonable:
However, note that my image's background's intensity is 1 and not 0. Hence, it should be reasonable to use cval=1:
imshow(gaussian_filter(g, sigma, order=1, mode='constant', cval=1))
Now this is unexpected! This result makes no sense, does it?
For the record, I also checked the partial differentials ∂/∂x G*f and ∂/∂y G*f. Whereas
imshow(gaussian_filter(g, sigma, order=[0, 1], mode='constant', cval=1)
looks reasonable
the other one
imshow(gaussian_filter(g, sigma, order=[1, 0], mode='constant', cval=1)
does not:
Why is that?





