computer vision - Not sure what this 'histogram code' is doing in MATLAB -



computer vision - Not sure what this 'histogram code' is doing in MATLAB -

i have next code given me, not sure @ logic here is. idea, believe, histogram/quantize data. here code:

the input:

x = 180.*rand(1,1000); %1000 points 0 180 degrees. binwidth = 20; %i want binwidth 20 degrees.

the main function:

% ------------------------------------------------------------------------- % compute closest bin center x1 less or equal x % ------------------------------------------------------------------------- function [x1, b1] = computelowerhistbin(x, binwidth) % bin index bin = floor(x./binwidth - 0.5); % bin center x1 x1 = binwidth * (bin + 0.5); % add together 2 1-based indexing b1 = bin + 2; end

finally, final 'quantized' data:

w = 1 - (x - x1)./binwidth

here not get: not understand - @ - why x1 computed way is, , why/how w computed way is. in fact, of things, w confuses me most. literally cannot understand logic here, or intended. appreciate detailed elucidation of logic. thanks.

he binning lb <= x < up , splitting interval [0,180] in [-10,10), [10, 30), [30,40) ..., [150,170), [170,190).

suppose x = 180, then:

bin = floor(180/20-0.5) = floor(9-0.5) = floor(8.5) = 8;

while if x = 0:

bin = floor(`0/20-0.5) = floor(-0.5) = floor(-1) = -1;

which respectively translate x1 = 20 * (8+0.5) = 170 , x1 = -10 seems function suggests lowerhistbin().

in end, w measures how far point x corresponding lower bin x1. notice w in (0,1], w beingness 1 when x = x1 , approaching 0 when x -> x1+binwidth. so, if x approaches 170, w approach 1 - (170-150)/20 = 0.

matlab computer-vision histogram matlab-cvst quantization

Comments

Popular posts from this blog

java Multi query from Mysql using netbeans -

c# - DotNetZip fails with "stream does not support seek operations" -

c++ - StartServiceCtrlDispatcher don't can access 1063 error -