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阅读 785评论 1 1
  • 回忆里的那个人 思念像是一张巨大而柔韧的蜘蛛网。 把我的世界织满。 我刚刚起床在刷牙, 我收拾完了准备去吃早饭, ...
    123现在阅读 305评论 0 5