Edge detection using first derivative operator in MATLAB
An edge in an image is a significant local change in image intensity, usually associated with a discontinuity in image intensity or the first derivative of image intensity. The discontinuities in the intensity of the image can be stepped discontinuities, in which the intensity of the image changes from one value on one side of the discontinuity to a different value on the opposite side, or a line discontinuity. , in which the intensity The image changes in value abruptly but then returns to the original value for a short distance. However, step and line edges are rare in actual images. Due to the low-frequency components or smoothing introduced by most detection devices, there are rarely any sharp discontinuities in the actual signals. The edges of the steps become the edges of the ramps, and the edges of the lines become the edges of the roof, where changes in intensity are not instantaneous but occur over a finite distance.
The discontinuity in the image brightness is called an edge.
Edge detection is the technique used to identify the regions in the image where the brightness of the image changes sharply. This sharp change in the intensity value is observed at the local minima or local maxima in the image histogram, using the first-order derivative.
Now we detect edge using the first derivative operator with different coordinates. To detect an edge using the forward operator we use given below steps:
- Read the image.
- Convert into grayscale if it is colored.
- Convert into the double format.
- Define the mask or filter.
- Detect the edges along X-axis.
- Detect the edges along Y-axis.
- Combine the edges detected along X and Y axes.
- Display all the images.
var_name = imread(” name of image . extension “);
var_name = rgb2gray ( old_image_var);
var_name = double(image);
mask = [1 -1 0];
Kx = conv2(image_var, mask, ‘same’);
Ky = conv2(image_var, mask’, ‘same’);
Final_image = sqrt ( Kx.^2 + Ky.^2);
Imtool() is the inbuilt function in Matlab. It is used to display the image. It takes 2 parameters; the first is the image variable and the second is the range of intensity values. We provide an empty list as the second argument which means the complete range of intensity has to be used while displaying the image.
Forward operator [1 -1 0]:
Central Operator [1 0 -1]:
Here, we can observe that the edge is more clearly visible.
Backward Operator [0 1 -1]: