Is it possible to replace Scalar quantization into vector Quantization in matlab?

2 次查看(过去 30 天)
I used binary quantizer and non-uniform quantizer under scalar quantization. Is it possible to replace the following code with vector quantization? If so how can I modify?
my code:
C_code = gen_binary_codes(C, K);
Ls = 3;
Lr = 5;
BINsi=Ls;
Wsi=BINsi.^(1:-1:0); % weights
BINc =2;
Wc=BINc.^(3:-1:0);
II=[1 2];JJ=[1 2 4 5];
SIcode = SI_code(:,II);
Ccode = C_code(:,JJ);
featW = SIcode*Wsi' + (Ccode*Wc')*BINsi^2;
H1=hist(featW, 0:(BINsi^2*BINc^4-1));
II=II+1; JJ=JJ+1;
SIcode = SI_code(:,II);
Ccode = C_code(:,JJ);
featW = SIcode*Wsi' + (Ccode*Wc')*BINsi^2;
H2=hist(featW, 0:(BINsi^2*BINc^4-1));
% H3
G2=C(:,1:3);
D2=C(:,4:6); % d
r=2/pi*atan(Coef*D2./G2);
R_code = atan_vq(r, Lr);
W=Lr.^(2:-1:0);
featW = R_code*W';
H3 = hist(featW, 0:Lr^3-1);

采纳的回答

Walter Roberson
Walter Roberson 2018-9-7
You can do non-uniform quantization of arrays in multiple ways:
  • histc passing in bin edges
  • hist passing in bin centers
  • histcounts() passing in either bin edges or bin centers with appropriate options
In the above three cases, you want to extract the bin number, which is the second output for histc or hist and the third output for histcounts. You then use the bin number as an index into an array of the representative value for each bin.
You can also quantize over arrays by using interp1() with the 'previous' or 'next' or 'nearest' option, like interp1(edges_list, representative_values_list, array_to_quantize, 'previous') . Here representative_values would be the same as the edges list if you wanted to quantize to the edge value but would be the edge centers if you wanted to quantize to the edge centers.

更多回答(0 个)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by