📄 edgestop.m
字号:
function g = edgestop( im, n, sigma )
% EDGESTOP Create the edge-stopping function
% G = EDGESTOP( IM, SIZE, SIGMA ) creates the edge-stopping
% function of 'im'. The image is first smoothed with a gaussian
% kernal of size 'n' and parameter 'sigma'
% first convolve the image with a gaussian filter to blur it
gauss_filter = fspecial( 'gaussian', n, sigma );
filtered_im = imfilter( im, gauss_filter );
% next create the gradient image by summing the horizontal
% and vertical gradient images
[ x_grad, y_grad ] = gradient( filtered_im );
grad_im = sqrt( ( x_grad.^2 ) + ( y_grad.^2 ) );
% scale the gradient image
max_grad = max( max( grad_im ) );
min_grad = min( min( grad_im ) );
grad_im = 10 .* ( grad_im - min_grad ) ./ ( max_grad - min_grad );
% Create the edge-stopping function, can also use:
%g = exp( -abs( grad_im ) );
g = 1 ./ ( 1 + abs( grad_im ) );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -