why do directional derivatives work better with a gaussian filter? I've been working on image segmentation and computing the directional derivatives of a grey-scaled image, with the objective of detecting contours and edges. I have realised that if I apply a gaussian filter before computing the directional derivatives, the edges get enhanced better. So my question is - why does that happen?

Here's the original image:



This is what the first order derivatives (dx and dy) look like (without gaussian filter):


here's the derivatives after applying gaussian filtering to the image, with sigma = 6:



*******Python code to compute the derivatives

with rio.open("vein_template.tif", 'r') as ds:
    RGB_arr = ds.read(masked=True)  # read all raster values
rgb_1 = np.rot90(np.transpose(RGB_arr, [1, 2, 0]))
#the rgb image contains 4 channels, so I'm changing their order, and making the image upright

%matplotlib
plt.imshow(rgb_1)

# Transform to grey-level img
gsi = 0.2989 * rgb_1[:, :, 0] + 0.5870 * rgb_1[:, :, 1] + 0.1140 * rgb_1[:, :, 2] 
plt.imshow(gsi, cmap = "gist_gray")

#compute derivatives
dx = np.diff(gsi, axis = 0)
dy = np.diff(gsi, axis = 1)

f = plt.figure()
f.add_subplot(1, 2, 1)
plt.imshow(dx, cmap = "Greys")
plt.title("dx")
f.add_subplot(1, 2, 2)
plt.imshow(dy, cmap = "Greys")
plt.title("dy")
Well, look at your original picture: it's constant for all points but the edges, which means your derivative is zero for all points but these edges.

By applying a "rounding, smoothing" filter to it, you "smear" the edges enough to make the derivative be non-zero for multiple pixels, in every direction.