matlab中计算图像的熵的程序有一点看不懂img = im2uint8(img); % Get size of img [r,c,b] = size(img); if b == 1 %s = shannon(img); hspec = imhist(img); idx = hspec == 0; * 请问这两句hspec(idx) = eps; hspec = hspec ./ (r * c); H = -(h
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/24 00:07:32
matlab中计算图像的熵的程序有一点看不懂img = im2uint8(img); % Get size of img [r,c,b] = size(img); if b == 1 %s = shannon(img); hspec = imhist(img); idx = hspec == 0; * 请问这两句hspec(idx) = eps; hspec = hspec ./ (r * c); H = -(h
matlab中计算图像的熵的程序有一点看不懂
img = im2uint8(img);
% Get size of img
[r,c,b] = size(img);
if b == 1
%s = shannon(img);
hspec = imhist(img);
idx = hspec == 0; * 请问这两句
hspec(idx) = eps;
hspec = hspec ./ (r * c);
H = -(hspec .* log2(hspec));
s = sum(H(:))
matlab中计算图像的熵的程序有一点看不懂img = im2uint8(img); % Get size of img [r,c,b] = size(img); if b == 1 %s = shannon(img); hspec = imhist(img); idx = hspec == 0; * 请问这两句hspec(idx) = eps; hspec = hspec ./ (r * c); H = -(h
idx = hspec == 0;%找出矩阵hspec中等于0的元素
hspec(idx) = eps; %令矩阵hspec中等于0的元素等于eps,eps是matlab中的一个常数,无限接近于0
例如:
>> x=0;
>> sin(x)/x
ans =
NaN
>> x=eps;
>> sin(x)/x
ans =
1