Edge detection :gradients

Derivatives(just like the theory of the smart car)

Edges in an image is really about the derivatives respect to the image function.As you can see:

圖片.png

These edges correspond to these extrema of the derivatives.

parital derivatives of an image

First we just make make the derivatives of the x or y directions.As you can see,the different templates we you to get the detivatives.

圖片.png

sobel operator

It not only watches the center of the op(operator),but also watches the nearby pixel.It is also the default op of the fun() in matlab:imgredientxy()

圖片.png

And other ops are listed below:

圖片.png

Matlab basically understand all of these:`

% Gradient Direction
function result = select_gdir(gmag, gdir, mag_min, angle_low, angle_high)
    % TODO Find and return pixels that fall within the desired mag, angle range
    result=gmag>=mag_min&gdir>=angle_low&gdir<=angle_high;
endfunction

pkg load image;

%% Load and convert image to double type, range [0, 1] for convenience
img = double(imread('octagon.png')) / 255.; 
imshow(img); % assumes [0, 1] range for double images

%% Compute x, y gradients
[gx gy] = imgradientxy(img, 'sobel'); % Note: gx, gy are not normalized

%% Obtain gradient magnitude and direction
[gmag gdir] = imgradient(gx, gy);
imshow(gmag / (4 * sqrt(2))); % mag = sqrt(gx^2 + gy^2), so [0, (4 * sqrt(2))]
imshow((gdir + 180.0) / 360.0); % angle in degrees [-180, 180]
%% Find pixels with desired gradient direction
my_grad = select_gdir(gmag, gdir, 1, 30, 60);% 45 +/- 15
%imshow(my_grad);  % NOTE: enable after you've implemented select_gdir

In the real world

What I'v said won't work without some extra handling!
The F(x) in the real word would be like this:

圖片.png

The noise has cause us to have the positive and negative derivatives all over the place.

圖片.png

So we basically apply smooth gradients somehow and look for some peaks.
And why we can do that?Because the linearity of the convolution as we can see below.We can apply the f before our derivatives.

圖片.png
圖片.png

2-D derivatives to find the maximum

圖片.png
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容

  • 葉隙 湖東 你告訴我, 天晴了, 我在東湖邊想著你, 陽光帶著縷縷暖意, 漏過葉隙; 你告訴我, 下雨了, 我在樹...
    39f7e9a0bf45閱讀 777評論 1 1
  • 回憶里的那個人 思念像是一張巨大而柔韌的蜘蛛網。 把我的世界織滿。 我剛剛起床在刷牙, 我收拾完了準備去吃早飯, ...
    123現在閱讀 305評論 0 5