indianla.blogg.se

Textra
Textra









textra

% b1 = erosion(x,g) % erosion b2 = dilation(b1,g) % opening b3 = dilation(b2,g) b4 = erosion(b3,g) % opening-closing % sub-function function y = MF_operator( x, g, operator ) % Morphological operators % a1 = dilation(x,g) % dilation a2 = erosion(a1,g) % closing a3 = erosion(a2,g) a4 = dilation(a3,g) % closing-opening % sub-function function e = erosion(f,g) % Morphological erosion operation N = length(f) M = length(g) ĭtmp = f for i = 1:N for j = 1:M if (i+j) >= 1 & (i+j) <= N tmp = f(i+j) - g(j) if tmp < dtmp(i) dtmp(i) = tmp end end end end

textra

% Sorting of local minimum and maximum points textra = zeros(1,length(tmin)+length(tmax)) xextra = zeros(1,length(xmin)+length(xmax)) if tmin(1) tmax(end) % The last extreme point is the minimum point textra(1) = tmin(1) xextra(1) = xmin(1) for i = 1:length(tmax) textra(2*i) = tmax(i) textra(2*i+1) = tmin(i+1) xextra(2*i) = xmax(i) xextra(2*i+1) = xmin(i+1) end else % The last extreme point is the maximum point for i = 1:length(tmax) textra(2*i-1) = tmin(i) textra(2*i) = tmax(i) xextra(2*i-1) = xmin(i) xextra(2*i) = xmax(i) end end else % The first extreme point is the maximum point if tmin(end) = 1 & (i-j) dtmp(i) dtmp(i) = tmp end end end end d = dtmp end

textra

Tmin = indmin tmax = indmax xmin = x(tmin) % The magnitude of the local minimum point xmax = x(tmax) % The magnitude of the local maximum point

textra

= extreme_points(x) % Determine the location of local minima and maxima % indmin - the position of the local minimum point in the sequence x % indmax - the position of the local maximum point in the sequence x X = x(:)-mean(x) % a vector N = length(x) % 'spline' - cubic spline interpolation % 'pchip' - cubic Hermitian interpolation % 'linear' - piecewise linear interpolation % 'nearest' - nearest neighbor interpolation % operator: selected morphological operator, see sub-function 'MF_operator' % % Output: % y: morphological filtered signal % % Input: % x: signal to be analyzed (a vector) % interp_method: selected interpllation method, such as 'spline', 'pchip', % 'linear' and 'nearest', in which 'spline' is recommended.











Textra