标签:
histroistatmomentslpfilterdftuvmatlab程序源代码itdip数字图像 |
分类: --草草-- |
(摘自冈萨雷斯的《数字图像处理(使用Matlab)》) :
l
% HISTROI Computes the histogram of an ROI in an image.
% [P,npix]=histroi(f,c,r) computes the histogram,P,of a
% polygonal region of interest (ROI) in image F.The polygonal
% region is defined by the colunm and row coordinates of its
% vertices, which are by the column and row coordinates of its
% respectively. All pixels of F must be >=0. Parameter NPIX is
% number of pixels in the polygonal region.
% ****from ggbondg****
% Generate the binary mask image.
B=roipoly(f,c,r);
% Compute the histogram of the pixels in the ROI.
P=imhist(f(B));
%Obtain the number of pixels in ROI if requested in the output.
if nargout>1
end
%****from ggbondg****
l
% STATMOMENTS Computes statistical central moments of image histogram.
% [v,unv]=statmoments(p,n) computes up to the Nth statistical
% central moment of a histogram whose components are in vector
% P. The length of must equal 256 or 65536.
% ****from ggbondg****
% The program outputs a V with V(1)=mean, V(2) = variance.
% V(3) = 3rd moment,...V(N)=Nth central moment. The random
% variable values are normalized to the range [0,1], so all
% moments also are in this range.
% ****from ggbondg****
% The program also outputs a Vector UNV containing the same moments
% as V,but using un-normalized random variable values (e.g., 0 to
% 255 if length(P)=2^8). For example, if length(P)=256 and V(1)
% = 0.5, then UNV(1) would have the value UNV(1)=127.5 (half of
% the [0 255] range).
%****from ggbondg****
Lp=length(p);
if (Lp~=256)&(Lp~=65536)
end
G=Lp-1;
% Make sure the histogram has unit area, and convert it to a
% column vector.
p=p/sum(p);
p=p(:);
% Form a vector of all the possible values of the
% random variable.
z=0:G;
%****from ggbondg****
% Now normalize the z's to the range [0,1].
z=z./G;
%****from ggbondg****
% The mean.
m=z*p;
%****from ggbondg****
% Cencter random variable about the mean.
z=z-m;
%****from ggbondg****
% Compute the central moments.
v=zeros(1,n);
v(1)=m;
for j=2:n
end
%****from ggbondg****
if nargout>1
end
%****from ggbondg****
l
% LPFILTER Computes frequency domain lowpass filters.
% H=lpfilter(type,M,N,D0,n) creates the transfer function of
% a lowpass filter ,H,of the specified TYPE and size (M-by-N).To
% view the filter as an image or mesh plot,it should be centered
% using H=fftshift(H).
% %****from ggbondg****
% Valid values for TYPE,D0,and n are:
% %****from ggbondg****
%
'ideal'
%
% %****from ggbondg****
%
'btw'
%
%
% 'gasussian'
%
%
%
% use function dftuv to set up the meshgrid arrays needed for
% computing the required distances.
[U,V]=dftuv(M,N);
%****from ggbondg****
% Compute the distances D(U,V).
D=sqrt(U.^2+V.^2);
%****from ggbondg****
% Begin filter computations.
switch type
end
%****from ggbondg****
l
% DFTUV Computes meshgrid frequency matrices.
% [U,V]=dftuv(M,N) computes meshgrid frequency matrices U and V.
% U and V are useful for computing frequency-domain filter
% functions.U and V are both M-by-N.
% %****from ggbondg****
% Set up range of variables.
u=0:M-1;
v=0:N-1;
%****from ggbondg****
% Compute the incides for use in meshgrid.
idx=find(u>M/2);
u(idx)=u(idx)-M;
idy=find(v>N/2);
v(idy)=v(idy)-N;
%****from ggbondg****
% Compute the meshgrid arrays.
[V,U]=meshgrid(v,u);
%****from ggbondg****

加载中…