我的matlab中没有entropy函数。 在线等它的源码。有的帮忙发下
2个回答
展开全部
function E = entropy(varargin)
%ENTROPY Entropy of intensity image.
% E = ENTROPY(I) returns E, a scalar value representing the entropy of an
% intensity image. Entropy is a statistical measure of randomness that can be
% used to characterize the texture of the input image. Entropy is defined as
% -sum(p.*log2(p)) where p contains the histogram counts returned from IMHIST.
%
% ENTROPY uses 2 bins in IMHIST for logical arrays and 256 bins for
% uint8, double or uint16 arrays.
%
% I can be multidimensional image. If I has more than two dimensions,
% it is treated as a multidimensional intensity image and not as an RGB image.
%
% Class Support
% -------------
% I must be logical, uint8, uint16, or double, and must be real, nonempty,
% and nonsparse. E is double.
%
% Notes
% -----
% ENTROPY converts any class other than logical to uint8 for the histogram
% count calculation so that the pixel values are discrete and directly
% correspond to a bin value.
%
% Example
% -------
% I = imread('circuit.tif');
% E = entropy(I)
%
% See also IMHIST, ENTROPYFILT.
% Copyright 1993-2007 The MathWorks, Inc.
% $Revision: 1.1.8.4 $ $Date: 2007/06/04 21:08:49 $
% Reference:
% Gonzalez, R.C., R.E. Woods, S.L. Eddins, "Digital Image Processing
% using MATLAB", Chapter 11.
I = ParseInputs(varargin{:});
if ~islogical(I)
I = im2uint8(I);
end
% calculate histogram counts
p = imhist(I(:));
% remove zero entries in p
p(p==0) = [];
% normalize p so that sum(p) is one.
p = p ./ numel(I);
E = -sum(p.*log2(p));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function I = ParseInputs(varargin)
iptchecknargin(1,1,nargin,mfilename);
iptcheckinput(varargin{1},{'uint8','uint16', 'double', 'logical'},...
{'real', 'nonempty', 'nonsparse'},mfilename, 'I',1);
I = varargin{1};
%ENTROPY Entropy of intensity image.
% E = ENTROPY(I) returns E, a scalar value representing the entropy of an
% intensity image. Entropy is a statistical measure of randomness that can be
% used to characterize the texture of the input image. Entropy is defined as
% -sum(p.*log2(p)) where p contains the histogram counts returned from IMHIST.
%
% ENTROPY uses 2 bins in IMHIST for logical arrays and 256 bins for
% uint8, double or uint16 arrays.
%
% I can be multidimensional image. If I has more than two dimensions,
% it is treated as a multidimensional intensity image and not as an RGB image.
%
% Class Support
% -------------
% I must be logical, uint8, uint16, or double, and must be real, nonempty,
% and nonsparse. E is double.
%
% Notes
% -----
% ENTROPY converts any class other than logical to uint8 for the histogram
% count calculation so that the pixel values are discrete and directly
% correspond to a bin value.
%
% Example
% -------
% I = imread('circuit.tif');
% E = entropy(I)
%
% See also IMHIST, ENTROPYFILT.
% Copyright 1993-2007 The MathWorks, Inc.
% $Revision: 1.1.8.4 $ $Date: 2007/06/04 21:08:49 $
% Reference:
% Gonzalez, R.C., R.E. Woods, S.L. Eddins, "Digital Image Processing
% using MATLAB", Chapter 11.
I = ParseInputs(varargin{:});
if ~islogical(I)
I = im2uint8(I);
end
% calculate histogram counts
p = imhist(I(:));
% remove zero entries in p
p(p==0) = [];
% normalize p so that sum(p) is one.
p = p ./ numel(I);
E = -sum(p.*log2(p));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function I = ParseInputs(varargin)
iptchecknargin(1,1,nargin,mfilename);
iptcheckinput(varargin{1},{'uint8','uint16', 'double', 'logical'},...
{'real', 'nonempty', 'nonsparse'},mfilename, 'I',1);
I = varargin{1};
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2011-07-05
展开全部
intensity image. Entropy is a statistical measure
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询