The x-derivative Sobel looks that way:
-1 0 +1
-2 0 +2
-1 0 +1
Lets say there are two samples of my image which look like that (0=black, 1=white):
0 0 1 1 0 0
0 0 1 & 1 0 0
0 0 1 1 0 0
If I perform convolution I'll end up with 4 and -4 respectively.
So my natural response would be to normalize the result by 8 and translate it by 0.5 - is that correct? (I am wondering as can't find Wikipedia etc. mentioning any normalization)
EDIT: I use the Sobel Filter to create a 2D Structure Tensor (with the derivatives dX and dY):
A B
Structure Tensor = C D
with A = dx^2
B = dx*dy
C = dx*dy
D = dy^2
Ultimately I want to store the result in [0,1], but right now I'm just wondering if I have to normalize the Sobel result (by default, not just in order to store it) or not, i.e.:
A = dx*dx
//OR
A = (dx/8.0)*(dx/8.0)
//OR
A = (dx/8.0+0.5)*(dx/8.0+0.5)
The Sobel filter is used for edge detection. It works by calculating the gradient of image intensity at each pixel within the image. It finds the direction of the largest increase from light to dark and the rate of change in that direction.
The Sobel filter is a type of filter to determine the edges in an image. It is typically implemented in a Convolutional Network as an activation layer and is a precursor for image identification. With this article at OpenGenus, you must have the complete idea of using Sobel filter used for edge detection.
Sobel filters belong to that class. A 1D derivative (enhancer) in horizontal or vertical direction, a 1D weighted average (smoother) in vertical or horizontal direction. Since they are linear, we can easily speak about frequencies, but high frequencies can be horizontal, vertical, diagonal.
The Sobel operator, sometimes called the Sobel–Feldman operator or Sobel filter, is used in image processing and computer vision, particularly within edge detection algorithms where it creates an image emphasising edges.
The Sobel filter is the composition of a finite difference filter in one dimension:
[ 1 0 -1 ] / 2
and a smoothing filter in the other dimension:
[ 1 2 1 ] / 4
Therefore, the proper normalization to the kernel as typically defined is 1/8.
This normalization is required when a correct estimate of the derivative is needed. When computing the gradient magnitude for detecting edges, the scaling is irrelevant.
The 1/4 in the smoothing filter is to normalize it to 1. The 1/2 in the finite difference filter comes from the distance between the two pixels compared. The derivative is defined as the limit of h to zero of [f(x+h)-f(x)]/h. For the finite difference approximation, we can choose h=1, leading to a filter [1,-1]
, or h=2, leading to the filter above. The advantage with h=2 is that the filter is symmetric, with h=1 you end up computing the derivative in the middle between the two pixels, thus the result is shifted by half a pixel.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With