您的位置:首页 > 运维架构

[cv]edge detection: 2d operators

2017-05-09 00:30 771 查看

derivative of 2d gaussian filter





Gaussian derivative in x,y direction



effect of sigma in smoothing filter



canny edge operator







in matlab, we can use command: edge(image, ‘canny’) easily.

In canny operator, thinning steps can be called non-maximal suppression.



How to link the line segments.









% For Your Eyes Only
pkg load image;

frizzy = imread('frizzy.png');
froomer = imread('froomer.png');
imshow(frizzy);
imshow(froomer);

gray_frizzy = rgb2gray(frizzy);
gray_froomer = rgb2gray(froomer);

% TODO: Find edges in frizzy and froomer images
frizzy_edges = edge(gray_frizzy,'canny');
froomer_edges = edge(gray_froomer, 'canny');

% TODO: Display common edge pixels
img = frizzy_edges | froomer_edges;
imshow(img);


matlab edge function help

edge - Find edges in intensity image

This MATLAB function returns a binary image BW containing 1s where the function

finds edges in the input image I and 0s elsewhere.

BW = edge(I)

BW = edge(I,’Sobel’)

BW = edge(I,’Sobel’,threshold)

BW = edge(I,’Sobel’,threshold,direction)

BW = edge(I,’Sobel’,threshold,direction,’nothinning’)

[BW,threshOut] = edge(I,’Sobel’,_)

BW = edge(I,’Prewitt’)

BW = edge(I,’Prewitt’,threshold)

BW = edge(I,’Prewitt’,threshold,direction)

BW = edge(I,’Prewitt’,threshold,direction,’nothinning’)

[BW,threshOut] = edge(I,’Prewitt’,_)

BW = edge(I,’Roberts’)

BW = edge(I,’Roberts’,threshold)

BW = edge(I,’Roberts’,threshold,’nothinning’)

[BW,threshOut] = edge(I,’Roberts’,threshold,’nothinning’)

BW = edge(I,’log’)

BW = edge(I,’log’,threshold)

BW = edge(I,’log’,threshold,sigma)

[BW,threshOut] = edge(I,’log’,_)

BW = edge(I,’zerocross’,threshold,h)

[BW,threshOut] = edge(I,’zerocross’,_)

BW = edge(I,’Canny’)

BW = edge(I,’Canny’,threshold)

BW = edge(I,’Canny’,threshold,sigma)

[BW,threshOut] = edge(I,’Canny’,_)

BW = edge(I,’approxcanny’)

BW = edge(I,’approxcanny’,threshold)

[gpuarrayBW,threshOut] = edge(gpuarrayI,_)

另请参阅 fspecial, gpuArray, imgradient, imgradientxy

edge 的参考页

名为 edge 的其他函数

sigma effect in Canny Edge Detection





single 2d edge detection filter



>> lena = imread('../pics/lena512color.tiff');
>> figure,imshow(lena),title('original image,colorful');
>> lenagray = rgb2gray(lena);
>> figure,imshow(lenagray),title('original image,gray');
>> h = fspecial('gaussian', [11,11],4);
>> figure,surf(h);
>> lenaSmooth = imfilter(lenagray,h);
>> figure,imshow(lenaSmooth);
>> % method 01: shift left and right, show difference
>> lenaL = lenagray;

>> lenaL(:,[1:end-1])=lenaL(:,[2:end]);
>> lenaL = lenaSmooth;
>> lenaL(:,[1:end-1])=lenaL(:,[2:end]);
>> lenaR = lenaSmooth;
>> lenaR(:,[2:end]) = lenaR(:,[1:end-1]);
>> lenaDiff = double(lenaR) - double(lenaL);
>> figure, imshow(lenaDiff,[]),title('difference between right and left shifted images');% because there exist negetive value use imshow(img,[])
>> %% method 2: Canny edge detector
>> cannyGray = edge(lenagray,'canny');
>> figure, imshow(cannyGray),title('edges in origin image');
>> cannySmooth = edge(lenaSmooth,'canny');
>> figure, imshow(cannySmooth),title('edges in smoothed image');
>> %% method 03: laplacian of gaussian
>> cannyLog = edge(lenagray,'log');
>> figure, imshow(cannyLog),title('edges in laplaced image');
>>










内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: