⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 plus_filt2d.m

📁 适用于matlab环境的源代码
💻 M
字号:
function [data_out, kernel] = plus_filt2D(data_in, x, mu, sigma, sigma_width)
% Function [data_out, kernel] = plus_filt2D(data_in, x, mu, sigma, sigma_width)
% function to calculate PLUS edge detector with 2D kernel. 
% Consist of Laplasian + Second-Derivative-in-the-Gradient-Direction combination
% This function convolves input image with set 2D Gaussian kernels then combines 
% results in accordance with formula given in reference paper.
%
%INPUTS:
%   DATA_IN     - input image
%   X           - size of Gaussian kernel.
%   MU          - mean of the Gaussian
%   SIGMA       - standard deviation of a Gaussian function
%   SIGMA_WIDTH - defines where to cut the Gaussian kernel tail (or width of the kernel in sigma).
%   Bigger number- more of Gaussian included in the kernel. Defaul value= 3 or 98% of Gaussian 
%
%OUTPUTS:
%   DATA_OUT- filtered data output
%   KERNEL - stucture with derivative kernels used for filtering:
%   {kernel.dGx, kernel.dGxx, kernel.dGxy}
%
%WARNING:   Derivatives for some pixels may be zero. This produce an error "divideByZero" and such 
%           pixels gets value =NaN. It is recomended to check for NaNs after filtering and replacing
%           it with value of convenience -> zero, global minimum,  etc...
%           To find all NaNs, Inf and -Inf and set them to zero you may use the following line:
%                       data_out(~isfinite(data_out)) = 0;
%
%EXAMPLES:
%X = imread('tire.tif'); imagesc(X); colormap gray; title('Original image')
%%This image can be found at \MATLAB704\toolbox\images\imdemos
%
%%Try one of the following:
%[dd, kernel] = plus_filt2D(X, 5);  dd = dd ./(max(dd(:)));
%figure; imagesc(dd> 0.1); colormap gray; colorbar
%[dd, kernel] = plus_filt2D(X, 11); dd = dd ./(max(dd(:)));
%figure; imagesc(dd> 0.1); colormap gray; colorbar
%
%%OR
%[dd, kernel] = plus_filt2D(X, 15, 0, 1, 2.5); 
%dd = dd ./(max(dd(:))); 
%figure; subplot(221); imagesc(dd> 0.1); %colormap gray
%title('Edge detected and thresholded image')
%subplot(222); surfl(kernel.dGx); colormap gray; shading interp
%title('kernel dGx'); axis tight
%subplot(223); surfl(kernel.dGxx); colormap gray; shading interp
%title('kernel dGxx'); axis tight
%subplot(224); surfl(kernel.dGxy); colormap gray; shading interp
%title('kernel dGxy'); axis tight
%
%REF: 
%1   Marr D., Hildreth E.C. in  揟heory of edge Detection

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -