In order to compute dradient magnitudes, we subtract two numbers along a direction of the image, typically along the x or y axis.
This is the best possible approximation of the image surface's slope as adjacency is the closest two pixel samples can get.
In order to compute this we treat it as a convolution with [-1, 1] or it's transpose. For added robustness to noise we combine this with a guassian filter to produce a Derivative of Gaussian Filter (DoG)
(542, 540, 3)
In the above image we can see highlighted either vertical horizontal edges, depending on which filter is used. (Dx = vertical)
Below we compare the result of applying the derivative and gaussian operators as separate kernels or combined kernels. (convolved together)
L1 Diff: 1.2297776192564738e-10 7.797023036980669e-11
Unsharpened vs Sharpened
Blurred vs Blurred + Sharpened
Unsharpened vs Sharpened
Blurred vs Blurred + Sharpened
(347, 560, 3) (347, 560, 3)
(290, 250, 1) (290, 250, 1) (290, 250, 1)
(771, 1024, 3) (771, 1024, 3)
Despite being aligned, the picture does not have the desired effect because the shape of cat and dog heads is too different.
(347, 560, 3) (347, 560, 3)
(771, 1024, 3) (771, 1024, 3)