资源简介
用于图像处理 图像分解 IMFs 可以将图像进行分解重构操作,适用于学习BEMD图像处理的同学。
代码片段和文件信息
%%
function [ imf_matrix ] = bemd( input_image )
% BEMD This program calculates the Bidimensional EMD of a 2-d signal using
% the process of sifting. It is dependent on the function SIFT.
tic
% Make a ‘double‘ copy of the image
input_image_d = cast(input_image‘double‘);
% Assigning the initial values of ‘h‘ (data for sifting) and ‘k‘ (imf index)
h_func = input_image_d;
k=1;
% The process of Sifting
while(k<4)
[imf_temp residue_temp] = sift(h_func);
imf_matrix(::k) = imf_temp; %#ok
k = k+1;
h_func = residue_temp;
end
% Assigning the final residue to the last IMF index
imf_matrix(::k) = residue_temp;
% End of BEMD Computation
toc
end
%%
function [ h_imf residue ] = sift( input_image )
% This function sifts for a single IMF of the given 2D signal input
% Pre-processing
[len bre] = size(input_image);
x = 1:len;
y = 1:bre;
input_image_temp = input_image;
while(1)
% Finding the extrema in the 2D signal
[zmax imax zmin imin] = extrema2(input_image_temp);
[xmax ymax] = ind2sub(size(input_image_temp)imax);
[xmin ymin] = ind2sub(size(input_image_temp)imin);
% Interpolating the extrema to get the extrema suraces
[zmaxgrid tmpx tmpx] = gridfit(ymaxxmaxzmaxyx);
[zmingrid tmpx tmpx] = gridfit(yminxminzminyx);
% Averaging the extrema to get the Zavg surface
zavggrid = (zmaxgrid + zmingrid)/2;
% Computation of the h_imf (IMF for the ‘h‘ input)
h_imf = input_image_temp - zavggrid;
% Computing IMF cost
eps = 0.00000001;
num = sum(sum((h_imf-input_image_temp).^2));
den = sum(sum((input_image_temp).^2)) + eps;
cost = num/den;
% Checking the IMF accuracy
if cost<0.2
break;
else
input_image_temp = h_imf;
end
end
% Computation of the Residue after IMF computation
residue = input_image - h_imf;
end
%%
function [xmaximaxxminimin] = extrema(x)
%EXTREMA Gets the global extrema points from a time series.
% [XMAXIMAXXMINIMIN] = EXTREMA(X) returns the global minima and maxima
% points of the vector X ignoring NaN‘s where
% XMAX - maxima points in descending order
% IMAX - indexes of the XMAX
% XMIN - minima points in descending order
% IMIN - indexes of the XMIN
%
% DEFINITION (from http://en.wikipedia.org/wiki/Maxima_and_minima):
% In mathematics maxima and minima also known as extrema are points in
% the domain of a function at which the function takes a largest value
% (maximum) or smallest value (minimum) either within a given
% neighbourhood (local extrema) or on the function domain in its entirety
% (global extrema).
%
% Example:
% x = 2*pi*linspace(-11);
% y = cos(x) - 0.5 + 0.5*rand(size(x)); y(40:45) = 1.85; y(50:53)=NaN;
% [ymaximaxyminimin] = extrema(y);
% plot(xyx(imax)ymax‘g.‘x(imin)ymin‘r.‘)
%
% See also EXTREMA2 MAX MIN
% Written by
% Lic. on Physics Carlos Adri醤 Vargas
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 45840 2011-05-02 21:03 bemd.m
文件 1343 2014-02-12 13:28 license.txt
评论
共有 条评论