【发布时间】:2014-10-13 21:08:06
【问题描述】:
我收到了以下代码,但我完全不确定这里的逻辑是什么。我相信这个想法是这将对我的数据进行直方图/量化。代码如下:
输入:
x = 180.*rand(1,1000); %1000 points from 0 to 180 degrees.
binWidth = 20; %I want the binWidth to be 20 degrees.
主要功能:
% -------------------------------------------------------------------------
% Compute the closest bin center x1 that is less than or equal to x
% -------------------------------------------------------------------------
function [x1, b1] = computeLowerHistBin(x, binWidth)
% Bin index
bin = floor(x./binWidth - 0.5);
% Bin center x1
x1 = binWidth * (bin + 0.5);
% add 2 to get to 1-based indexing
b1 = bin + 2;
end
最后,最终的“量化”数据:
w = 1 - (x - x1)./binWidth
这是我不明白的:我完全不明白为什么 x1 是按原样计算的,以及为什么/如何按原样计算 w。事实上,在所有事情中,w 最让我困惑。我真的无法理解这里的逻辑,或者真正的意图。希望能详细说明这个逻辑。谢谢。
【问题讨论】:
标签: matlab computer-vision histogram matlab-cvst quantization