Reference:
Https://www.cnblogs.com/dengdan890730/p/6145585.html
https://blog.csdn.net/touch_dream/article/details/62447801
https://blog.csdn.net/xiahn1a/article/details/42141429
https://blog.csdn.net/swj110119/article/details/51777422 what is the edge.
Edge generally refers to a region in which the intensity of a local area of the image changes dramatically. The intensity change generally has 2 medium, step effect and roof effect. The task of edge detection is to find a set of pixels with step changes or roof changes. Step Effect
So what is the step effect.
As shown in the figure below, where the horizontal axis of the axes represents the spatial variation, the vertical axis represents the grayscale change, and the dashed line represents the edge.
Roof Effect
the principle of edge detection
Fundamentals of Edge Detection:
Since the edge is the most drastic change in the gray level, the most intuitive idea is to seek differentiation.
(1) For the first case: the peak value of one-order differential is the edge point, and the 0 point of the second derivative is the edge point.
Specifically, from the step effect of the graph can be seen at the edge of the slope (first-order) the largest, so the first-order differential peak is the edge point, and the slope is increased first and then decreased, that is, the edge point of the second-order 0.
(2) for the second case: the 0 point of the first order differential is the edge point, and the peak of the second derivative is the edge point. the difference between first-order guide and second derivative extraction edge
The edges of the
Laplace extract are obtained by using the second-order derivation edge, while the Sobel,prewitt,roberts-difference method is the first derivative to seek the edge. So naturally we have to ask, what is the difference between the first derivative and the edge of the second derivative extraction? The
(1) first-order derivative usually produces a thicker edge. The
(2) Second derivative has a strong response to fine details, such as thin lines, outliers, and noise. The second derivative of the
(3) has a bilateral response at the gray-scale ramp and the gray step transition. The
(4) Second derivative symbol determines whether the edge transitions from light to dark or from dark to light. The
(5) Second derivative is more sensitive to detail.
Normal, it's best to do the image smoothing before extracting the edges , because the derivative is more sensitive to noise. Laplace operator extract Edge
The
Laplace extract edge belongs to the edge extraction using second-order derivative, which is an isotropic edge extracting operator. Isotropic refers to the use of this operator, can be any direction of the line and line sharpening, no directionality. And, like Sobel, they are implemented using different operators to extract the edges of the x and y directions. This Laplace operator distinguishes itself from the advantages of other first-order differential operators. But its drawbacks are noise-sensitive compared to the first-order differential. It responds more strongly to orphaned pixels than to edges or lines, so applies only to noise-free images . Because the Laplace operator is sensitive to outliers and noises. We use the Gaussian smoothing image before extracting the edges using the Laplace operator, which is the Laplacian-gauss (LOG) operator. It combines the Gaussian smoothing filter and the Laplacian sharpening filter, smoothing out noise first, and then edge detection, so the effect is better. The
has 2 representations of its formula, which are all equivalent, as shown below. (1)
its corresponding matrix form is as follows:
————————————————————————————————————
(2)
its corresponding matrix is as follows:
However, it is important to note that the original image and the Laplace When the second derivative of the image is merged, the differences in the symbols must be considered. That is, the original image and the Laplace of the image between the end with a plus or minus, and the center point f (x, y) coefficient. Specifically, if the coefficients in front of the center pixel are negative, the original image is subtracted from the Laplace derivative image. If it is positive, the original image will be added Laplace derivative image.
If you use the center coefficient as positive and still use the original image minus the convolution of the Laplace operator as if the center coefficient is negative, you will see that the image becomes blurred.
In addition to the usual use of the following 2 kinds of extended form of the Laplace operator.
Laplace operator enhancement image (MATLAB code)
CLC;
Clear;
Close all;
% img = imread (' images/lena_gray.jpg ');
img = imread (' images/lena.jpg ');
IMG =im2double (IMG);
% Laplace operator Form 1
% Lapla =[0,-1,0;-1,4,-1;0,-1,0];
% Laplace operator Form 2
lapla =[0,1,0;1,-4,1;0,1,0];
Img_lapla = IMFilter (Img,lapla, ' replicate ', ' same ');
Figure;imshow (IMG_LAPLA); title (' Laplace ');
% use Form 1 o'clock to add
% Img_f = img +img_lapla;
% use Form 2 o'clock to subtract
img_f = Img-img_lapla;
% using the following statement causes the image to be blurred instead of enhanced
%img_f = img +img_lapla;
Figure;imshow (Img_f); title (' Enhanced ');
Sobel, Prewitt, Roberts operators
The
(1) Roberts operator has the edge positioning, but is sensitive to noise. Suitable for image segmentation with obvious edges and less noise. As with all first-order derivative operators, the result of Roberts is also a wide response. The Roberts operator form is as follows:
(2) The Prewitt operator has an inhibitory effect on noise, the principle of noise suppression is by the average pixel, but the average pixel equivalent to the image of low-pass filtering, low-pass filtering will cause high-frequency information loss, so that the image blurred, regardless of this degree or large or small, The result of this operation is there, so the Prewitt operator is inferior to the Roberts operator in locating the edge.
(3) The Sobel operator is an improved form of the Prewitt operator, and the improvement is that the Sobel operator believes that the influence of the neighboring pixels on the current pixel is not equivalent, so the distance of different pixels has different weights, and the effect on operator results is different. In general, the farther away the distance, the less impact it has. Because the Sobel operator has a weighted effect on the position of pixels, it is better than the Prewitt operator and the Roberts operator. Compared with Prewitt operator, the Sobel template can suppress (smooth) noise better. Sobel is more accurate than Prewitt to detect image edges.
%%%%%%%%%%% of the (%) of the (%) of the (%) of the (%) of the (%) of the (%) of the (%)% of the% of the
Get%% more accurate edge. %%%% La Plaze operator is a 2-order differential operator, that is, the equivalent of 2 differential,% of its accuracy is relatively high, but the noise is too sensitive (poor effect in the case of noise) is its major disadvantage,%% so this operator is not particularly used. The Sobel operator is the most commonly used
One of the sub (it is a first-order operator),%% of the method simple effect is also good, but the extraction of the edge is relatively coarse, to be refined processing.
%%%% Sobel operator is improved on the basis of the Prewitt operator, using a weighted value of 2 on the center coefficient,%% compared to the Prewitt operator, the Sobel template is able to better smooth the noise.
%%%%%% of% of% of% of% of% of% of%
Clear
Close all;
img = imread (' images/lena.jpg ');
img = im2double (IMG);
[Height,width,ch] = Size (IMG);
% if ch ==3% img = Rgb2gray (IMG);
% end percent uses Laplace operator to extract edge Lapla = [0,1,0;1,-4,1;0,1,0];
Img_log = IMFilter (Img,lapla, ' replicate ', ' same ');
Figure;imshow (Img_log); title (' Laplace ');
Percent use Sobel operator HX = fspecial (' Sobel ');
IMGX = IMFilter (img,hx, ' replicate ', ' same ');
hy = HX ';
Imgy = IMFilter (img,hy, ' replicate ', ' same ');
Imgxy = sqrt (imgx.^2+imgy.^2);
Figure;imshow (imgxy,[]); title (' Sobel extract edge '); Percent use Prewitt operator HX = fspecial (' Prewitt');
IMGX = IMFilter (img,hx, ' replicate ');
hy = HX ';
Imgy = IMFilter (img,hy, ' replicate ');
Imgxy = sqrt (imgx.^2+imgy.^2);
Figure;imshow (imgxy,[]); title (' Prewitt operator extracts edge ');
Percent use differential Ix = [diff (img,1,1); IMG (1,:,:)-img (end,:,:)]; Iy = [diff (img,1,2), IMG (:, 1,:)-img (:, end,:)]; imgxy = sqrt (ix.^2 + iy.^2); Figure;imshow (imgxy,[]); Title (' Differential Method for Edge ');