edgestop.m
来自「Image segmentation script (code)」· M 代码 · 共 24 行
M
24 行
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 + =
减小字号Ctrl + -
显示快捷键?